diff --git a/Cargo.toml b/Cargo.toml index 0de0a1d4070b9eb0178722f50088942ceaba5809..560dfed03556515aef0ffd51febd75c3bc17ff9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,8 @@ license = "MIT OR Apache-2.0" readme = "README.md" +edition = "2021" + [dependencies] safemem = "0.3" memchr = "2.0" diff --git a/src/lib.rs b/src/lib.rs index 6a5365a0fd11f4d1a8b2c1e0c6ba9d6c0a2236bb..c5da85f9d630d9adc6bbd7e2945416e2411d6283 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -370,8 +370,8 @@ impl BufReader { } /// Box the inner reader without losing data. - pub fn boxed<'a>(self) -> BufReader, P> where R: 'a { - let inner: Box = Box::new(self.inner); + pub fn boxed<'a>(self) -> BufReader, P> where R: 'a { + let inner: Box = Box::new(self.inner); BufReader { inner, @@ -864,11 +864,7 @@ impl Into for IntoInnerError { } impl error::Error for IntoInnerError { - fn description(&self) -> &str { - error::Error::description(self.error()) - } - - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { Some(&self.1) } } @@ -1047,7 +1043,7 @@ impl Buffer { } let read = { - let mut buf = unsafe { self.buf.write_buf() }; + let buf = unsafe { self.buf.write_buf() }; rdr.read(buf)? }; @@ -1065,7 +1061,7 @@ impl Buffer { /// space, this returns 0. pub fn copy_from_slice(&mut self, src: &[u8]) -> usize { let len = unsafe { - let mut buf = self.buf.write_buf(); + let buf = self.buf.write_buf(); let len = cmp::min(buf.len(), src.len()); buf[..len].copy_from_slice(&src[..len]); len @@ -1270,7 +1266,7 @@ pub fn copy_buf(b: &mut B, w: &mut W) -> io::Result { } thread_local!( - static DROP_ERR_HANDLER: RefCell> + static DROP_ERR_HANDLER: RefCell> = RefCell::new(Box::new(|_, _, _| ())) ); @@ -1283,7 +1279,7 @@ thread_local!( /// ### Panics /// If called from within a handler previously provided to this function. pub fn set_drop_err_handler(handler: F) -where F: Fn(&mut Write, &mut Buffer, io::Error) +where F: Fn(&mut dyn Write, &mut Buffer, io::Error) { DROP_ERR_HANDLER.with(|deh| *deh.borrow_mut() = Box::new(handler)) } diff --git a/src/policy.rs b/src/policy.rs index c2ab54bf0411b1b98ca26a2f6d0123128e7c9024..a2fece62753978bfd69147a42edf6c6c40c9c760 100644 --- a/src/policy.rs +++ b/src/policy.rs @@ -22,8 +22,8 @@ pub struct DoRead(pub bool); /// Shorthand for `return DoRead(bool)` or `return DoRead(true)` (empty invocation) #[macro_export] macro_rules! do_read ( - ($val:expr) => ( return $crate::policy::DoRead($val); ); - () => ( do_read!(true); ) + ($val:expr) => ( return $crate::policy::DoRead($val) ); + () => ( do_read!(true) ) ); /// Default policy for both `BufReader` and `BufWriter` that reproduces the behaviors of their