Skip to content

Commit

Permalink
Use "{:?}" format specifier for Show
Browse files Browse the repository at this point in the history
  • Loading branch information
alkor committed Jan 11, 2015
1 parent 7b1596d commit 435b629
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::io::println;
use url::Url;

fn main() {
format!("{}", Get);
format!("{:?}", Get);
let args = os::args();
match args.len() {
0 => unreachable!(),
Expand All @@ -34,8 +34,8 @@ fn make_and_print_request(url: &str) {
println!("=======");
println!("");
println!("URL: {}", request.url);
println!("[1mRemote address:[0m {}", request.remote_addr);
println!("[1mMethod:[0m {}", request.method);
println!("[1mRemote address:[0m {:?}", request.remote_addr);
println!("[1mMethod:[0m {:?}", request.method);
println!("Headers:");
for header in request.headers.iter() {
println!(" - {}: {}", header.header_name(), header.header_value());
Expand All @@ -49,7 +49,7 @@ fn make_and_print_request(url: &str) {
Ok(response) => response,
Err(_request) => panic!("This example can progress no further with no response :-("),
};
println!("[1mStatus:[0m {}", response.status);
println!("[1mStatus:[0m {:?}", response.status);
println!("Headers:");
for header in response.headers.iter() {
println!(" - {}: {}", header.header_name(), header.header_value());
Expand Down
10 changes: 5 additions & 5 deletions examples/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ impl Server for InfoServer {

w.write(b"<h1>Request</h1>").unwrap();
let s = format!("<dl>
<dt>Method</dt><dd>{}</dd>
<dt>Host</dt><dd>{}</dd>
<dt>Request URI</dt><dd>{}</dd>
<dt>HTTP version</dt><dd>{}</dd>
<dt>Method</dt><dd>{:?}</dd>
<dt>Host</dt><dd>{:?}</dd>
<dt>Request URI</dt><dd>{:?}</dd>
<dt>HTTP version</dt><dd>{:?}</dd>
<dt>Close connection</dt><dd>{}</dd></dl>",
r.method,
r.headers.host,
Expand All @@ -58,7 +58,7 @@ impl Server for InfoServer {
w.write(b"</pre>").unwrap();

w.write(b"<h1>Response</h1>").unwrap();
let s = format!("<dl><dt>Status</dt><dd>{}</dd></dl>", w.status);
let s = format!("<dl><dt>Status</dt><dd>{:?}</dd></dl>", w.status);
w.write(s.as_bytes()).unwrap();
w.write(b"<h2>Headers</h2>").unwrap();
w.write(b"<table><thead><tr><th>Name</th><th>Value</th></thead><tbody>").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/http/client/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl<S: Connecter + Reader + Writer = super::NetworkStream> RequestWriter<S> {
None => ("", "")
};
try!(write!(self.stream.as_mut().unwrap() as &mut Writer,
"{} {}{}{} HTTP/1.0\r\n",
"{:?} {}{}{} HTTP/1.0\r\n",
self.method, self.url.serialize_path().unwrap(), question_mark, query));

try!(self.headers.write_all(self.stream.as_mut().unwrap()));
Expand Down
2 changes: 1 addition & 1 deletion src/http/client/sslclients/openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn lift_ssl_error(ssl: SslError) -> IoError {
OpenSslErrors(errs) => IoError {
kind: OtherIoError,
desc: "Error in OpenSSL",
detail: Some(format!("{}", errs))
detail: Some(format!("{:?}", errs))
}
}
}
2 changes: 1 addition & 1 deletion src/http/headers/content_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl super::HeaderConvertible for MediaType {
}

fn http_value(&self) -> String {
format!("{}", self)
format!("{:?}", self)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/http/headers/etag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl super::HeaderConvertible for EntityTag {
}

fn http_value(&self) -> String {
format!("{}", self)
format!("{:?}", self)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/http/headers/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ impl super::HeaderConvertible for Host {
}

fn http_value(&self) -> String {
format!("{}", self)
format!("{:?}", self)
}
}
2 changes: 1 addition & 1 deletion src/http/headers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ impl HeaderConvertible for Method {
}

fn http_value(&self) -> String {
format!("{}", self)
format!("{:?}", self)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/http/server/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<'a> ResponseWriter<'a> {
// XXX: might be better not to hardcode HTTP/1.1.
// XXX: Rust's current lack of statement-duration lifetime handling prevents this from being
// one statement ("error: borrowed value does not live long enough")
let s = format!("HTTP/1.1 {}\r\n", self.status);
let s = format!("HTTP/1.1 {:?}\r\n", self.status);
try!(self.writer.write(s.as_bytes()));

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

0 comments on commit 435b629

Please sign in to comment.