cargo fix --all

* it added "dyn" to trait objects
* it changed "..." in patterns to "..="

cargo --version says: "cargo 1.37.0-nightly (545f35425 2019-05-23)"
This commit is contained in:
Scott Lamb
2019-06-14 08:47:11 -07:00
parent 7dd98bb76a
commit 7fe9d34655
22 changed files with 83 additions and 83 deletions

View File

@@ -39,8 +39,8 @@ use std::error::Error as StdError;
pub struct Chunk(ARefs<'static, [u8]>);
//pub type CompatError = ::failure::Compat<Error>;
pub type BoxedError = Box<StdError + Send + Sync>;
pub type BodyStream = Box<Stream<Item = Chunk, Error = BoxedError> + Send + 'static>;
pub type BoxedError = Box<dyn StdError + Send + Sync>;
pub type BodyStream = Box<dyn Stream<Item = Chunk, Error = BoxedError> + Send + 'static>;
pub fn wrap_error(e: Error) -> BoxedError {
Box::new(e.compat())

View File

@@ -265,7 +265,7 @@ pub fn run() -> Result<(), Error> {
// Start the web interface.
let addr = args.flag_http_addr.parse().unwrap();
let server = ::hyper::server::Server::bind(&addr).tcp_nodelay(true).serve(
move || Ok::<_, Box<StdError + Send + Sync>>(s.clone()));
move || Ok::<_, Box<dyn StdError + Send + Sync>>(s.clone()));
let shutdown = setup_shutdown().shared();

View File

@@ -641,7 +641,7 @@ impl slices::Slice for Slice {
fn end(&self) -> u64 { return self.0 & 0xFF_FF_FF_FF_FF }
fn get_range(&self, f: &File, range: Range<u64>, len: u64)
-> Box<Stream<Item = Self::Chunk, Error = BoxedError> + Send> {
-> Box<dyn Stream<Item = Self::Chunk, Error = BoxedError> + Send> {
trace!("getting mp4 slice {:?}'s range {:?} / {}", self, range, len);
let p = self.p();
let res = match self.t() {
@@ -1518,7 +1518,7 @@ impl http_serve::Entity for File {
fn etag(&self) -> Option<HeaderValue> { Some(self.0.etag.clone()) }
fn len(&self) -> u64 { self.0.slices.len() }
fn get_range(&self, range: Range<u64>)
-> Box<Stream<Item = Self::Data, Error = Self::Error> + Send> {
-> Box<dyn Stream<Item = Self::Data, Error = Self::Error> + Send> {
self.0.slices.get_range(self, range)
}
}

View File

@@ -52,7 +52,7 @@ pub trait Slice : fmt::Debug + Sized + Sync + 'static {
/// The additional argument `ctx` is as supplied to the `Slices`.
/// The additional argument `l` is the length of this slice, as determined by the `Slices`.
fn get_range(&self, ctx: &Self::Ctx, r: Range<u64>, len: u64)
-> Box<Stream<Item = Self::Chunk, Error = BoxedError> + Send>;
-> Box<dyn Stream<Item = Self::Chunk, Error = BoxedError> + Send>;
fn get_slices(ctx: &Self::Ctx) -> &Slices<Self>;
}
@@ -111,7 +111,7 @@ impl<S> Slices<S> where S: Slice {
/// Writes `range` to `out`.
/// This interface mirrors `http_serve::Entity::write_to`, with the additional `ctx` argument.
pub fn get_range(&self, ctx: &S::Ctx, range: Range<u64>)
-> Box<Stream<Item = S::Chunk, Error = BoxedError> + Send> {
-> Box<dyn Stream<Item = S::Chunk, Error = BoxedError> + Send> {
if range.start > range.end || range.end > self.len {
return Box::new(stream::once(Err(wrap_error(format_err_t!(
Internal, "Bad range {:?} for slice of length {}", range, self.len)))));
@@ -176,7 +176,7 @@ mod tests {
fn end(&self) -> u64 { self.end }
fn get_range(&self, _ctx: &&'static Slices<FakeSlice>, r: Range<u64>, _l: u64)
-> Box<Stream<Item = FakeChunk, Error = BoxedError> + Send> {
-> Box<dyn Stream<Item = FakeChunk, Error = BoxedError> + Send> {
Box::new(stream::once(Ok(FakeChunk{slice: self.name, range: r})))
}

View File

@@ -43,7 +43,7 @@ pub static ROTATE_INTERVAL_SEC: i64 = 60;
/// Common state that can be used by multiple `Streamer` instances.
pub struct Environment<'a, 'b, C, S> where C: Clocks + Clone, S: 'a + stream::Stream {
pub opener: &'a stream::Opener<S>,
pub opener: &'a dyn stream::Opener<S>,
pub db: &'b Arc<Database<C>>,
pub shutdown: &'b Arc<AtomicBool>,
}
@@ -57,7 +57,7 @@ pub struct Streamer<'a, C, S> where C: Clocks + Clone, S: 'a + stream::Stream {
db: Arc<Database<C>>,
dir: Arc<dir::SampleFileDir>,
syncer_channel: writer::SyncerChannel<::std::fs::File>,
opener: &'a stream::Opener<S>,
opener: &'a dyn stream::Opener<S>,
stream_id: i32,
short_name: String,
url: String,

View File

@@ -798,7 +798,7 @@ impl Service {
///
/// Use with `and_then` to chain logic which consumes the form body.
fn with_form_body(&self, mut req: Request<hyper::Body>)
-> Box<Future<Item = (Request<hyper::Body>, hyper::Chunk),
-> Box<dyn Future<Item = (Request<hyper::Body>, hyper::Chunk),
Error = Response<Body>> +
Send + 'static> {
if *req.method() != http::method::Method::POST {
@@ -911,11 +911,11 @@ impl ::hyper::service::Service for Service {
type ReqBody = ::hyper::Body;
type ResBody = Body;
type Error = BoxedError;
type Future = Box<Future<Item = Response<Self::ResBody>, Error = Self::Error> + Send + 'static>;
type Future = Box<dyn Future<Item = Response<Self::ResBody>, Error = Self::Error> + Send + 'static>;
fn call(&mut self, req: Request<::hyper::Body>) -> Self::Future {
fn wrap<R>(is_private: bool, r: R)
-> Box<Future<Item = Response<Body>, Error = BoxedError> + Send + 'static>
-> Box<dyn Future<Item = Response<Body>, Error = BoxedError> + Send + 'static>
where R: Future<Item = Response<Body>, Error = Response<Body>> + Send + 'static {
return Box::new(r.or_else(|e| Ok(e)).map(move |mut r| {
if is_private {
@@ -926,7 +926,7 @@ impl ::hyper::service::Service for Service {
}
fn wrap_r(is_private: bool, r: ResponseResult)
-> Box<Future<Item = Response<Body>, Error = BoxedError> + Send + 'static> {
-> Box<dyn Future<Item = Response<Body>, Error = BoxedError> + Send + 'static> {
return wrap(is_private, future::result(r))
}
@@ -1009,7 +1009,7 @@ mod tests {
}).unwrap();
let server = hyper::server::Server::bind(&addr)
.tcp_nodelay(true)
.serve(move || Ok::<_, Box<StdError + Send + Sync>>(service.clone()));
.serve(move || Ok::<_, Box<dyn StdError + Send + Sync>>(service.clone()));
let addr = server.local_addr(); // resolve port 0 to a real ephemeral port number.
let handle = ::std::thread::spawn(move || {
::tokio::run(server.with_graceful_shutdown(shutdown_rx).map_err(|e| panic!(e)));