Skip to content

Commit 435b629

Browse files
committed
Use "{:?}" format specifier for Show
See rust-lang/rust#20013
1 parent 7b1596d commit 435b629

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

examples/client.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::io::println;
1414
use url::Url;
1515

1616
fn main() {
17-
format!("{}", Get);
17+
format!("{:?}", Get);
1818
let args = os::args();
1919
match args.len() {
2020
0 => unreachable!(),
@@ -34,8 +34,8 @@ fn make_and_print_request(url: &str) {
3434
println!("=======");
3535
println!("");
3636
println!("URL: {}", request.url);
37-
println!("[1mRemote address:[0m {}", request.remote_addr);
38-
println!("[1mMethod:[0m {}", request.method);
37+
println!("[1mRemote address:[0m {:?}", request.remote_addr);
38+
println!("[1mMethod:[0m {:?}", request.method);
3939
println!("Headers:");
4040
for header in request.headers.iter() {
4141
println!(" - {}: {}", header.header_name(), header.header_value());
@@ -49,7 +49,7 @@ fn make_and_print_request(url: &str) {
4949
Ok(response) => response,
5050
Err(_request) => panic!("This example can progress no further with no response :-("),
5151
};
52-
println!("[1mStatus:[0m {}", response.status);
52+
println!("[1mStatus:[0m {:?}", response.status);
5353
println!("Headers:");
5454
for header in response.headers.iter() {
5555
println!(" - {}: {}", header.header_name(), header.header_value());

examples/info.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ impl Server for InfoServer {
3333

3434
w.write(b"<h1>Request</h1>").unwrap();
3535
let s = format!("<dl>
36-
<dt>Method</dt><dd>{}</dd>
37-
<dt>Host</dt><dd>{}</dd>
38-
<dt>Request URI</dt><dd>{}</dd>
39-
<dt>HTTP version</dt><dd>{}</dd>
36+
<dt>Method</dt><dd>{:?}</dd>
37+
<dt>Host</dt><dd>{:?}</dd>
38+
<dt>Request URI</dt><dd>{:?}</dd>
39+
<dt>HTTP version</dt><dd>{:?}</dd>
4040
<dt>Close connection</dt><dd>{}</dd></dl>",
4141
r.method,
4242
r.headers.host,
@@ -58,7 +58,7 @@ impl Server for InfoServer {
5858
w.write(b"</pre>").unwrap();
5959

6060
w.write(b"<h1>Response</h1>").unwrap();
61-
let s = format!("<dl><dt>Status</dt><dd>{}</dd></dl>", w.status);
61+
let s = format!("<dl><dt>Status</dt><dd>{:?}</dd></dl>", w.status);
6262
w.write(s.as_bytes()).unwrap();
6363
w.write(b"<h2>Headers</h2>").unwrap();
6464
w.write(b"<table><thead><tr><th>Name</th><th>Value</th></thead><tbody>").unwrap();

src/http/client/request.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl<S: Connecter + Reader + Writer = super::NetworkStream> RequestWriter<S> {
237237
None => ("", "")
238238
};
239239
try!(write!(self.stream.as_mut().unwrap() as &mut Writer,
240-
"{} {}{}{} HTTP/1.0\r\n",
240+
"{:?} {}{}{} HTTP/1.0\r\n",
241241
self.method, self.url.serialize_path().unwrap(), question_mark, query));
242242

243243
try!(self.headers.write_all(self.stream.as_mut().unwrap()));

src/http/client/sslclients/openssl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn lift_ssl_error(ssl: SslError) -> IoError {
7272
OpenSslErrors(errs) => IoError {
7373
kind: OtherIoError,
7474
desc: "Error in OpenSSL",
75-
detail: Some(format!("{}", errs))
75+
detail: Some(format!("{:?}", errs))
7676
}
7777
}
7878
}

src/http/headers/content_type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl super::HeaderConvertible for MediaType {
7171
}
7272

7373
fn http_value(&self) -> String {
74-
format!("{}", self)
74+
format!("{:?}", self)
7575
}
7676
}
7777

src/http/headers/etag.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl super::HeaderConvertible for EntityTag {
6666
}
6767

6868
fn http_value(&self) -> String {
69-
format!("{}", self)
69+
format!("{:?}", self)
7070
}
7171
}
7272

src/http/headers/host.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ impl super::HeaderConvertible for Host {
4141
}
4242

4343
fn http_value(&self) -> String {
44-
format!("{}", self)
44+
format!("{:?}", self)
4545
}
4646
}

src/http/headers/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ impl HeaderConvertible for Method {
666666
}
667667

668668
fn http_value(&self) -> String {
669-
format!("{}", self)
669+
format!("{:?}", self)
670670
}
671671
}
672672

src/http/server/response.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'a> ResponseWriter<'a> {
7272
// XXX: might be better not to hardcode HTTP/1.1.
7373
// XXX: Rust's current lack of statement-duration lifetime handling prevents this from being
7474
// one statement ("error: borrowed value does not live long enough")
75-
let s = format!("HTTP/1.1 {}\r\n", self.status);
75+
let s = format!("HTTP/1.1 {:?}\r\n", self.status);
7676
try!(self.writer.write(s.as_bytes()));
7777

7878
// FIXME: this is not an impressive way of handling it, but so long as chunked is the only

0 commit comments

Comments
 (0)