Some final rustfmt changes.
This commit is contained in:
@@ -49,13 +49,10 @@ impl Body {
|
|||||||
pub fn read_to_string(mut body: Body) -> ::std::io::Result<String> {
|
pub fn read_to_string(mut body: Body) -> ::std::io::Result<String> {
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
match body.reader {
|
match body.reader {
|
||||||
Kind::Reader(ref mut reader, _) => {
|
Kind::Reader(ref mut reader, _) => reader.read_to_string(&mut s),
|
||||||
reader.read_to_string(&mut s)
|
Kind::Bytes(ref mut bytes) => (&**bytes).read_to_string(&mut s),
|
||||||
}
|
}
|
||||||
Kind::Bytes(ref mut bytes) => {
|
.map(|_| s)
|
||||||
(&**bytes).read_to_string(&mut s)
|
|
||||||
}
|
|
||||||
}.map(|_| s)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Kind {
|
enum Kind {
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ static DEFAULT_USER_AGENT: &'static str =
|
|||||||
pub fn spawn(txns: Vec<(Vec<u8>, Vec<u8>)>) -> Server {
|
pub fn spawn(txns: Vec<(Vec<u8>, Vec<u8>)>) -> Server {
|
||||||
let listener = net::TcpListener::bind("127.0.0.1:0").unwrap();
|
let listener = net::TcpListener::bind("127.0.0.1:0").unwrap();
|
||||||
let addr = listener.local_addr().unwrap();
|
let addr = listener.local_addr().unwrap();
|
||||||
thread::spawn(move || {
|
thread::spawn(
|
||||||
for (mut expected, reply) in txns {
|
move || for (mut expected, reply) in txns {
|
||||||
let (mut socket, _addr) = listener.accept().unwrap();
|
let (mut socket, _addr) = listener.accept().unwrap();
|
||||||
replace_expected_vars(&mut expected, addr.to_string().as_ref(), DEFAULT_USER_AGENT.as_ref());
|
replace_expected_vars(&mut expected, addr.to_string().as_ref(), DEFAULT_USER_AGENT.as_ref());
|
||||||
let mut buf = [0; 4096];
|
let mut buf = [0; 4096];
|
||||||
@@ -33,7 +33,7 @@ pub fn spawn(txns: Vec<(Vec<u8>, Vec<u8>)>) -> Server {
|
|||||||
}
|
}
|
||||||
socket.write_all(&reply).unwrap();
|
socket.write_all(&reply).unwrap();
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
Server {
|
Server {
|
||||||
addr: addr,
|
addr: addr,
|
||||||
|
|||||||
Reference in New Issue
Block a user