summaryrefslogtreecommitdiffstats
path: root/buffered-reader/src/lib.rs
diff options
context:
space:
mode:
authorWiktor Kwapisiewicz <wiktor@metacode.biz>2023-05-30 12:03:15 +0200
committerWiktor Kwapisiewicz <wiktor@metacode.biz>2023-06-06 10:37:51 +0200
commitf5f9b14a304321816526c30ce98edbd6535df9c4 (patch)
treeccc0f752f9e1ea1037bd4f37a59a52387cd9e7fb /buffered-reader/src/lib.rs
parent4f3d260a013835a8ab0b2f15f45e22ca4678ab24 (diff)
buffered_reader: Introduce `into_boxed` and deprecate `as_boxed`.
- According to the Rust API Guidelines, a conversion function taking self should be called `into_*` if the self is not Copy, so this function should be named `into_boxed`. - Deprecate old function not to break the API. - Update all references in the code. - Fixes https://gitlab.com/sequoia-pgp/sequoia/-/issues/781
Diffstat (limited to 'buffered-reader/src/lib.rs')
-rw-r--r--buffered-reader/src/lib.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/buffered-reader/src/lib.rs b/buffered-reader/src/lib.rs
index a130ca7c..d52b3e0e 100644
--- a/buffered-reader/src/lib.rs
+++ b/buffered-reader/src/lib.rs
@@ -915,11 +915,19 @@ pub trait BufferedReader<C> : io::Read + fmt::Debug + fmt::Display + Send + Sync
}
/// Boxes the reader.
+ fn into_boxed<'a>(self) -> Box<dyn BufferedReader<C> + 'a>
+ where Self: 'a + Sized
+ {
+ Box::new(self)
+ }
+
+ /// Boxes the reader.
#[allow(clippy::wrong_self_convention)]
+ #[deprecated(note = "Use into_boxed")]
fn as_boxed<'a>(self) -> Box<dyn BufferedReader<C> + 'a>
where Self: 'a + Sized
{
- Box::new(self)
+ self.into_boxed()
}
/// Returns the underlying reader, if any.
@@ -1066,6 +1074,12 @@ impl <'a, C: fmt::Debug + Sync + Send> BufferedReader<C> for Box<dyn BufferedRea
self.as_ref().get_ref()
}
+ fn into_boxed<'b>(self) -> Box<dyn BufferedReader<C> + 'b>
+ where Self: 'b
+ {
+ self
+ }
+
fn as_boxed<'b>(self) -> Box<dyn BufferedReader<C> + 'b>
where Self: 'b
{