diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2022-06-19 13:12:21 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2022-06-19 13:12:21 -0300 |
commit | 2e832974be3009d09a32fd8e03fa7acab7b7f435 (patch) | |
tree | 9a885df23d4e08d1dee48f5d08ea0ac80ff9c67b /src | |
parent | 9cc8c6d516281cd23db770169ed764899268f12a (diff) |
Deprecate trait SelfRef
It isn't needed
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/src/lib.rs b/src/lib.rs index ef8d67d..c1697b9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,14 +35,12 @@ //! use selfref::Holder; //! use selfref::NewWith; //! use selfref::OperateIn; -//! use selfref::SelfRef; //! use selfref::opaque; //! //! struct Foo<'a, 'b: 'a> { //! foo: Cell<Option<&'a Foo<'a, 'b>>>, //! t: &'b str, //! } -//! impl<'a, 'b> SelfRef<'a> for Foo<'a, 'b> {} //! //! struct FooKey<'b>(PhantomData<&'b str>); //! opaque! { @@ -98,8 +96,8 @@ use core::mem; /// } /// impl<'a> SelfRef<'a> for Foo<'a> {} /// ``` -pub trait SelfRef<'a> { -} +#[deprecated(since = "0.1.3", note = "wasn't needed, can be safely removed")] +pub trait SelfRef<'a> {} /// An opaqueified self-referential struct "key". /// @@ -122,13 +120,11 @@ pub trait SelfRef<'a> { /// /// use core::cell::Cell; /// -/// use selfref::SelfRef; /// use selfref::Opaque; /// /// struct Foo<'a> { /// foo: Cell<Option<&'a Foo<'a>>>, /// } -/// impl<'a> SelfRef<'a> for Foo<'a> {} /// /// struct FooKey; /// // SAFETY: Foo has no Drop impl and has the same layout for any 'a. @@ -138,7 +134,7 @@ pub trait SelfRef<'a> { /// ``` pub unsafe trait Opaque { /// The actual self-referential struct. - type Kind<'a>: SelfRef<'a> where Self: 'a; + type Kind<'a> where Self: 'a; #[doc(hidden)] fn ub_check() { } @@ -162,13 +158,11 @@ pub unsafe trait Opaque { /// /// use core::cell::Cell; /// -/// use selfref::SelfRef; /// use selfref::opaque; /// /// struct Foo<'a> { /// foo: Cell<Option<&'a Foo<'a>>>, /// } -/// impl<'a> SelfRef<'a> for Foo<'a> {} /// /// struct FooKey; /// opaque! { @@ -187,14 +181,12 @@ pub unsafe trait Opaque { /// use core::fmt::Display; /// use core::marker::PhantomData; /// -/// use selfref::SelfRef; /// use selfref::opaque; /// /// struct Foo<'a, T: Display> { /// foo: Cell<Option<&'a Foo<'a, T>>>, /// t: T, /// } -/// impl<'a, T: Display> SelfRef<'a> for Foo<'a, T> {} /// /// struct FooKey<T>(PhantomData<T>); /// opaque! { @@ -264,7 +256,6 @@ macro_rules! opaque { /// use core::cell::Cell; /// /// use selfref::Holder; -/// use selfref::SelfRef; /// use selfref::new_with_closure; /// use selfref::opaque; /// @@ -272,7 +263,6 @@ macro_rules! opaque { /// struct Foo<'a> { /// foo: Cell<Option<&'a Foo<'a>>>, /// } -/// impl<'a> SelfRef<'a> for Foo<'a> {} /// /// struct FooKey; /// opaque! { @@ -331,7 +321,6 @@ impl<'k, T> Holder<'k, T> where T: Opaque { /// use core::cell::Cell; /// /// use selfref::Holder; - /// use selfref::SelfRef; /// use selfref::new_with_closure; /// use selfref::opaque; /// @@ -339,7 +328,6 @@ impl<'k, T> Holder<'k, T> where T: Opaque { /// struct Foo<'a> { /// foo: Cell<Option<&'a Foo<'a>>>, /// } - /// impl<'a> SelfRef<'a> for Foo<'a> {} /// /// struct FooKey; /// opaque! { @@ -366,14 +354,12 @@ impl<'k, T> Holder<'k, T> where T: Opaque { /// /// use selfref::Holder; /// use selfref::NewWith; - /// use selfref::SelfRef; /// use selfref::opaque; /// /// struct Foo<'a, 'b: 'a> { /// foo: Cell<Option<&'a Foo<'a, 'b>>>, /// t: &'b str, /// } - /// impl<'a, 'b> SelfRef<'a> for Foo<'a, 'b> {} /// /// struct FooKey<'b>(PhantomData<&'b str>); /// opaque! { @@ -422,7 +408,8 @@ pub trait OperateIn<'k, T: Opaque + 'k> { fn operate_in<'a>(self, x: Pin<&'a T::Kind<'a>>) -> Self::Out where 'k: 'a; } -impl<'k, T: Opaque + 'k, F, R> OperateIn<'k, T> for F where F: for<'a> FnOnce(Pin<&'a T::Kind<'a>>) -> R { +impl<'k, T: Opaque + 'k, F, R> OperateIn<'k, T> for F +where F: for<'a> FnOnce(Pin<&'a T::Kind<'a>>) -> R { type Out = R; fn operate_in<'a>(self, x: Pin<&'a T::Kind<'a>>) -> R where 'k: 'a { self(x) @@ -455,7 +442,6 @@ impl<'k, T> Holder<'k, T> where T: Opaque { /// use core::pin::pin; /// /// use selfref::Holder; - /// use selfref::SelfRef; /// use selfref::new_with_closure; /// use selfref::opaque; /// use selfref::operate_in_closure; @@ -464,7 +450,6 @@ impl<'k, T> Holder<'k, T> where T: Opaque { /// struct Foo<'a> { /// foo: Cell<Option<&'a Foo<'a>>>, /// } - /// impl<'a> SelfRef<'a> for Foo<'a> {} /// /// struct FooKey; /// opaque! { @@ -500,14 +485,12 @@ impl<'k, T> Holder<'k, T> where T: Opaque { /// use selfref::Holder; /// use selfref::NewWith; /// use selfref::OperateIn; - /// use selfref::SelfRef; /// use selfref::opaque; /// /// struct Foo<'a, 'b: 'a> { /// foo: Cell<Option<&'a Foo<'a, 'b>>>, /// t: &'b str, /// } - /// impl<'a, 'b> SelfRef<'a> for Foo<'a, 'b> {} /// /// struct FooKey<'b>(PhantomData<&'b str>); /// opaque! { @@ -547,11 +530,13 @@ impl<'k, T> Holder<'k, T> where T: Opaque { F: OperateIn<'k, T, Out=R> { /// Converts Pin<&'a T::Kind<'k>> to Pin<&'b T::Kind<'b>> - unsafe fn upcast_dangling<'a, 'b, 'c, T: Opaque + 'c>(x: Pin<&'a T::Kind<'c>>) -> Pin<&'b T::Kind<'b>> + unsafe fn upcast_dangling<'a, 'b, 'c, T: Opaque + 'c>( + x: Pin<&'a T::Kind<'c>>, + ) -> Pin<&'b T::Kind<'b>> where T::Kind<'c>: 'a { mem::transmute(x) } - + f.operate_in(unsafe { upcast_dangling::<'i, 'k, '_, T> (self.map_unchecked(|self_ref| { @@ -573,7 +558,6 @@ impl<'k, T> Holder<'k, T> where T: Opaque { /// use core::pin::pin; /// /// use selfref::Holder; -/// use selfref::SelfRef; /// use selfref::new_with_closure; /// use selfref::opaque; /// use selfref::operate_in_closure; @@ -582,7 +566,6 @@ impl<'k, T> Holder<'k, T> where T: Opaque { /// struct Foo<'a> { /// foo: Option<&'a UnsafeCell<Foo<'a>>>, /// } -/// impl<'a> SelfRef<'a> for Foo<'a> {} /// /// struct FooKey; /// opaque! { @@ -605,6 +588,7 @@ impl<'k, T> Holder<'k, T> where T: Opaque { /// ); /// } /// ``` +#[allow(deprecated)] impl<'a, T: SelfRef<'a>> SelfRef<'a> for core::cell::UnsafeCell<T> {} /// Allows working with holders to `Cell`. @@ -619,7 +603,6 @@ impl<'a, T: SelfRef<'a>> SelfRef<'a> for core::cell::UnsafeCell<T> {} /// use core::pin::pin; /// /// use selfref::Holder; -/// use selfref::SelfRef; /// use selfref::new_with_closure; /// use selfref::opaque; /// use selfref::operate_in_closure; @@ -628,7 +611,6 @@ impl<'a, T: SelfRef<'a>> SelfRef<'a> for core::cell::UnsafeCell<T> {} /// struct Foo<'a> { /// foo: Option<&'a Cell<Foo<'a>>>, /// } -/// impl<'a> SelfRef<'a> for Foo<'a> {} /// /// struct FooKey; /// opaque! { @@ -651,6 +633,7 @@ impl<'a, T: SelfRef<'a>> SelfRef<'a> for core::cell::UnsafeCell<T> {} /// ); /// } /// ``` +#[allow(deprecated)] impl<'a, T: SelfRef<'a>> SelfRef<'a> for core::cell::Cell<T> {} /// Allows working with holders to `RefCell`. @@ -665,7 +648,6 @@ impl<'a, T: SelfRef<'a>> SelfRef<'a> for core::cell::Cell<T> {} /// use core::pin::pin; /// /// use selfref::Holder; -/// use selfref::SelfRef; /// use selfref::new_with_closure; /// use selfref::opaque; /// use selfref::operate_in_closure; @@ -674,7 +656,6 @@ impl<'a, T: SelfRef<'a>> SelfRef<'a> for core::cell::Cell<T> {} /// struct Foo<'a> { /// foo: Option<&'a RefCell<Foo<'a>>>, /// } -/// impl<'a> SelfRef<'a> for Foo<'a> {} /// /// struct FooKey; /// opaque! { @@ -695,4 +676,5 @@ impl<'a, T: SelfRef<'a>> SelfRef<'a> for core::cell::Cell<T> {} /// ); /// } /// ``` +#[allow(deprecated)] impl<'a, T: SelfRef<'a>> SelfRef<'a> for core::cell::RefCell<T> {} |