diff options
55 files changed, 259 insertions, 259 deletions
diff --git a/buffered-reader/src/decompress_bzip2.rs b/buffered-reader/src/decompress_bzip2.rs index cd27864e..dff2a202 100644 --- a/buffered-reader/src/decompress_bzip2.rs +++ b/buffered-reader/src/decompress_bzip2.rs @@ -100,16 +100,16 @@ impl<R: BufferedReader<C>, C> BufferedReader<C> for Bzip<R, C> { return self.reader.steal_eof(); } - fn get_mut(&mut self) -> Option<&mut BufferedReader<C>> { + fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>> { Some(self.reader.reader.get_mut()) } - fn get_ref(&self) -> Option<&BufferedReader<C>> { + fn get_ref(&self) -> Option<&dyn BufferedReader<C>> { Some(self.reader.reader.get_ref()) } fn into_inner<'b>(self: Box<Self>) - -> Option<Box<BufferedReader<C> + 'b>> where Self: 'b { + -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { // Strip the outer box. Some(Box::new(self.reader.reader.into_inner())) } diff --git a/buffered-reader/src/decompress_deflate.rs b/buffered-reader/src/decompress_deflate.rs index 13a9f201..f31322ac 100644 --- a/buffered-reader/src/decompress_deflate.rs +++ b/buffered-reader/src/decompress_deflate.rs @@ -101,16 +101,16 @@ impl<R: BufferedReader<C>, C> BufferedReader<C> return self.reader.steal_eof(); } - fn get_mut(&mut self) -> Option<&mut BufferedReader<C>> { + fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>> { Some(self.reader.reader.get_mut()) } - fn get_ref(&self) -> Option<&BufferedReader<C>> { + fn get_ref(&self) -> Option<&dyn BufferedReader<C>> { Some(self.reader.reader.get_ref()) } fn into_inner<'b>(self: Box<Self>) - -> Option<Box<BufferedReader<C> + 'b>> where Self: 'b { + -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { // Strip the outer box. Some(Box::new(self.reader.reader.into_inner())) } @@ -223,16 +223,16 @@ impl<R: BufferedReader<C>, C> BufferedReader<C> return self.reader.steal_eof(); } - fn get_mut(&mut self) -> Option<&mut BufferedReader<C>> { + fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>> { Some(self.reader.reader.get_mut()) } - fn get_ref(&self) -> Option<&BufferedReader<C>> { + fn get_ref(&self) -> Option<&dyn BufferedReader<C>> { Some(self.reader.reader.get_ref()) } fn into_inner<'b>(self: Box<Self>) - -> Option<Box<BufferedReader<C> + 'b>> where Self: 'b { + -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { // Strip the outer box. Some(Box::new(self.reader.reader.into_inner())) } diff --git a/buffered-reader/src/dup.rs b/buffered-reader/src/dup.rs index edebc373..e5a5d895 100644 --- a/buffered-reader/src/dup.rs +++ b/buffered-reader/src/dup.rs @@ -11,7 +11,7 @@ use super::*; /// much data as you read. Thus, it should only be used for peeking /// at the underlying `BufferedReader`. pub struct Dup<'a, C> { - reader: Box<'a + BufferedReader<C>>, + reader: Box<dyn BufferedReader<C> + 'a>, // The number of bytes that have been consumed. cursor: usize, @@ -40,7 +40,7 @@ impl<'a> Dup<'a, ()> { /// Instantiates a new `Dup` buffered reader. /// /// `reader` is the `BufferedReader` to duplicate. - pub fn new(reader: Box<'a + BufferedReader<()>>) -> Self { + pub fn new(reader: Box<dyn BufferedReader<()> + 'a>) -> Self { Self::with_cookie(reader, ()) } } @@ -50,7 +50,7 @@ impl<'a, C> Dup<'a, C> { /// /// The cookie can be retrieved using the `cookie_ref` and /// `cookie_mut` methods, and set using the `cookie_set` method. - pub fn with_cookie(reader: Box<'a + BufferedReader<C>>, cookie: C) -> Self { + pub fn with_cookie(reader: Box<dyn BufferedReader<C> + 'a>, cookie: C) -> Self { Dup { reader: reader, cursor: 0, @@ -121,15 +121,15 @@ impl<'a, C> BufferedReader<C> for Dup<'a, C> { Ok(data) } - fn get_mut(&mut self) -> Option<&mut BufferedReader<C>> { + fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>> { Some(&mut self.reader) } - fn get_ref(&self) -> Option<&BufferedReader<C>> { + fn get_ref(&self) -> Option<&dyn BufferedReader<C>> { Some(&self.reader) } - fn into_inner<'b>(self: Box<Self>) -> Option<Box<BufferedReader<C> + 'b>> + fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { Some(self.reader) } diff --git a/buffered-reader/src/eof.rs b/buffered-reader/src/eof.rs index c5a27e56..928cd518 100644 --- a/buffered-reader/src/eof.rs +++ b/buffered-reader/src/eof.rs @@ -72,18 +72,18 @@ impl<C> BufferedReader<C> for EOF<C> { } } - fn into_inner<'a>(self: Box<Self>) -> Option<Box<BufferedReader<C> + 'a>> + fn into_inner<'a>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'a>> where Self: 'a { return None; } - fn get_mut(&mut self) -> Option<&mut BufferedReader<C>> + fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>> { return None; } - fn get_ref(&self) -> Option<&BufferedReader<C>> + fn get_ref(&self) -> Option<&dyn BufferedReader<C>> { return None; } diff --git a/buffered-reader/src/file_generic.rs b/buffered-reader/src/file_generic.rs index 3c83bb73..d1eb20e1 100644 --- a/buffered-reader/src/file_generic.rs +++ b/buffered-reader/src/file_generic.rs @@ -71,15 +71,15 @@ impl<C> BufferedReader<C> for File<C> { self.0.data_consume_hard(amount) } - fn get_mut(&mut self) -> Option<&mut BufferedReader<C>> { + fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>> { None } - fn get_ref(&self) -> Option<&BufferedReader<C>> { + fn get_ref(&self) -> Option<&dyn BufferedReader<C>> { None } - fn into_inner<'b>(self: Box<Self>) -> Option<Box<BufferedReader<C> + 'b>> + fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { None } diff --git a/buffered-reader/src/file_unix.rs b/buffered-reader/src/file_unix.rs index c2e1f912..5f6ebb75 100644 --- a/buffered-reader/src/file_unix.rs +++ b/buffered-reader/src/file_unix.rs @@ -204,15 +204,15 @@ impl<'a, C> BufferedReader<C> for File<'a, C> { } } - fn get_mut(&mut self) -> Option<&mut BufferedReader<C>> { + fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>> { None } - fn get_ref(&self) -> Option<&BufferedReader<C>> { + fn get_ref(&self) -> Option<&dyn BufferedReader<C>> { None } - fn into_inner<'b>(self: Box<Self>) -> Option<Box<BufferedReader<C> + 'b>> + fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { None } diff --git a/buffered-reader/src/generic.rs b/buffered-reader/src/generic.rs index 16f962b9..8c29bb09 100644 --- a/buffered-reader/src/generic.rs +++ b/buffered-reader/src/generic.rs @@ -252,15 +252,15 @@ impl<T: io::Read, C> BufferedReader<C> for Generic<T, C> { return self.data_helper(amount, true, true); } - fn get_mut(&mut self) -> Option<&mut BufferedReader<C>> { + fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>> { None } - fn get_ref(&self) -> Option<&BufferedReader<C>> { + fn get_ref(&self) -> Option<&dyn BufferedReader<C>> { None } - fn into_inner<'b>(self: Box<Self>) -> Option<Box<BufferedReader<C> + 'b>> + fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { None } diff --git a/buffered-reader/src/lib.rs b/buffered-reader/src/lib.rs index d0e10ffb..f3099343 100644 --- a/buffered-reader/src/lib.rs +++ b/buffered-reader/src/lib.rs @@ -799,7 +799,7 @@ pub trait BufferedReader<C> : io::Read + fmt::Debug + fmt::Display { /// ```text /// let inner = Box::new(br).into_inner(); /// ``` - fn into_inner<'a>(self: Box<Self>) -> Option<Box<BufferedReader<C> + 'a>> + fn into_inner<'a>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'a>> where Self: 'a; /// Returns a mutable reference to the inner `BufferedReader`, if @@ -809,10 +809,10 @@ pub trait BufferedReader<C> : io::Read + fmt::Debug + fmt::Display { /// `BufferedReader`, because this `BufferedReader` may have some /// data buffered. However, this function can be useful to get /// the cookie. - fn get_mut(&mut self) -> Option<&mut BufferedReader<C>>; + fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>>; /// Returns a reference to the inner `BufferedReader`, if any. - fn get_ref(&self) -> Option<&BufferedReader<C>>; + fn get_ref(&self) -> Option<&dyn BufferedReader<C>>; /// Sets the `BufferedReader`'s cookie and returns the old value. fn cookie_set(&mut self, cookie: C) -> C; @@ -865,7 +865,7 @@ pub fn buffered_reader_generic_read_impl<T: BufferedReader<C>, C> } /// Make a `Box<BufferedReader>` look like a BufferedReader. -impl <'a, C> BufferedReader<C> for Box<BufferedReader<C> + 'a> { +impl <'a, C> BufferedReader<C> for Box<dyn BufferedReader<C> + 'a> { fn buffer(&self) -> &[u8] { return self.as_ref().buffer(); } @@ -924,17 +924,17 @@ impl <'a, C> BufferedReader<C> for Box<BufferedReader<C> + 'a> { return self.as_mut().drop_eof(); } - fn get_mut(&mut self) -> Option<&mut BufferedReader<C>> { + fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>> { // Strip the outer box. self.as_mut().get_mut() } - fn get_ref(&self) -> Option<&BufferedReader<C>> { + fn get_ref(&self) -> Option<&dyn BufferedReader<C>> { // Strip the outer box. self.as_ref().get_ref() } - fn into_inner<'b>(self: Box<Self>) -> Option<Box<BufferedReader<C> + 'b>> + fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { // Strip the outer box. (*self).into_inner() diff --git a/buffered-reader/src/limitor.rs b/buffered-reader/src/limitor.rs index 7c371467..23ff342a 100644 --- a/buffered-reader/src/limitor.rs +++ b/buffered-reader/src/limitor.rs @@ -6,7 +6,7 @@ use super::*; /// Limits the amount of data that can be read from a /// `BufferedReader`. pub struct Limitor<'a, C> { - reader: Box<'a + BufferedReader<C>>, + reader: Box<dyn BufferedReader<C> + 'a>, limit: u64, cookie: C, @@ -32,7 +32,7 @@ impl<'a> Limitor<'a, ()> { /// /// `reader` is the source to wrap. `limit` is the maximum number /// of bytes that can be read from the source. - pub fn new(reader: Box<'a + BufferedReader<()>>, limit: u64) -> Self { + pub fn new(reader: Box<dyn BufferedReader<()> + 'a>, limit: u64) -> Self { Self::with_cookie(reader, limit, ()) } } @@ -42,7 +42,7 @@ impl<'a, C> Limitor<'a, C> { /// /// The cookie can be retrieved using the `cookie_ref` and /// `cookie_mut` methods, and set using the `cookie_set` method. - pub fn with_cookie(reader: Box<'a + BufferedReader<C>>, limit: u64, cookie: C) + pub fn with_cookie(reader: Box<dyn BufferedReader<C> + 'a>, limit: u64, cookie: C) -> Limitor<'a, C> { Limitor { reader: reader, @@ -124,15 +124,15 @@ impl<'a, C> BufferedReader<C> for Limitor<'a, C> { self.limit == 0 } - fn get_mut(&mut self) -> Option<&mut BufferedReader<C>> { + fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<C>> { Some(&mut self.reader) } - fn get_ref(&self) -> Option<&BufferedReader<C>> { + fn get_ref(&self) -> Option<&dyn BufferedReader<C>> { Some(&self.reader) } - fn into_inner<'b>(self: Box<Self>) -> Option<Box<BufferedReader<C> + 'b>> + fn into_inner<'b>(self: Box<Self>) -> Option<Box<dyn BufferedReader<C> + 'b>> where Self: 'b { Some(self.reader) } @@ -162,7 +162,7 @@ mod test { /* Add a single limitor. */ { - let mut bio : Box<BufferedReader<()>> + let mut bio : Box<dyn BufferedReader<()>> = Box::new(Memory::new(data)); bio = { @@ -200,15 +200,15 @@ mod test { /* Try with two limitors where the first one imposes the real |