Cargo fmt

This commit is contained in:
Tim Kuehn
2017-01-22 20:01:22 -08:00
parent 45fa4c7bf1
commit 3196fd91ff
5 changed files with 16 additions and 18 deletions

View File

@@ -14,7 +14,8 @@ extern crate env_logger;
extern crate futures;
use futures::Future;
use tarpc::sync::Connect;
use tarpc::{client, server};
use tarpc::client::sync::Connect;
use tarpc::util::{FirstSocketAddr, Never};
#[cfg(test)]
use test::Bencher;
@@ -28,7 +29,7 @@ struct Server;
impl FutureService for Server {
type AckFut = futures::Finished<(), Never>;
fn ack(&mut self) -> Self::AckFut {
fn ack(&self) -> Self::AckFut {
futures::finished(())
}
}
@@ -37,10 +38,8 @@ impl FutureService for Server {
#[bench]
fn latency(bencher: &mut Bencher) {
let _ = env_logger::init();
let addr = Server.listen("localhost:0".first_socket_addr()).wait().unwrap();
let mut client = SyncClient::connect(addr).unwrap();
let addr = Server.listen("localhost:0".first_socket_addr(), server::Options::default()).wait().unwrap();
let client = SyncClient::connect(addr, client::Options::default()).unwrap();
bencher.iter(|| {
client.ack().unwrap();
});
bencher.iter(|| { client.ack().unwrap(); });
}

View File

@@ -77,8 +77,7 @@ fn bench_tcp(target: u64) {
let addr = l.local_addr().unwrap();
thread::spawn(move || {
let (mut stream, _) = l.accept().unwrap();
while let Ok(_) = stream.write_all(&*BUF) {
}
while let Ok(_) = stream.write_all(&*BUF) {}
});
let mut stream = net::TcpStream::connect(&addr).unwrap();
let mut buf = vec![0; CHUNK_SIZE as usize];

View File

@@ -112,6 +112,7 @@ impl Options {
/// Exposes a trait for connecting asynchronously to servers.
pub mod future {
use super::{Client, Options};
use {REMOTE, Reactor};
use futures::{self, Async, Future, future};
use protocol::Proto;
@@ -119,7 +120,6 @@ pub mod future {
use std::io;
use std::marker::PhantomData;
use std::net::SocketAddr;
use super::{Client, Options};
use tokio_core::{self, reactor};
use tokio_core::net::TcpStream;
use tokio_proto::BindClient;
@@ -231,12 +231,12 @@ pub mod future {
/// Exposes a trait for connecting synchronously to servers.
pub mod sync {
use super::{Client, Options};
use client::future::Connect as FutureConnect;
use futures::{Future, future};
use serde::{Deserialize, Serialize};
use std::io;
use std::net::ToSocketAddrs;
use super::{Client, Options};
use util::FirstSocketAddr;
/// Types that can connect to a server synchronously.

View File

@@ -706,10 +706,10 @@ mod functional_test {
}
mod sync {
use {client, server};
use client::sync::Connect;
use super::{SyncClient, SyncService, SyncServiceExt};
use super::env_logger;
use {client, server};
use client::sync::Connect;
use util::FirstSocketAddr;
use util::Never;
@@ -753,11 +753,11 @@ mod functional_test {
}
mod future {
use super::{FutureClient, FutureService, FutureServiceExt};
use super::env_logger;
use {client, server};
use client::future::Connect;
use futures::{Finished, Future, finished};
use super::{FutureClient, FutureService, FutureServiceExt};
use super::env_logger;
use util::FirstSocketAddr;
use util::Never;

View File

@@ -75,9 +75,9 @@ pub fn listen<S, Req, Resp, E>(new_service: S, addr: SocketAddr, options: Option
/// Spawns a service that binds to the given address using the given handle.
fn listen_with<S, Req, Resp, E>(new_service: S,
addr: SocketAddr,
handle: Handle)
-> io::Result<SocketAddr>
addr: SocketAddr,
handle: Handle)
-> io::Result<SocketAddr>
where S: NewService<Request = Result<Req, DeserializeError>,
Response = Response<Resp, E>,
Error = io::Error> + Send + 'static,