deref_owned
This crate provides a smart pointer Owned
, which points to a value that can
be borrowed from an owned inner value. It's similar to
Cow
, except that it's
always owning a value.
Moreover, a trait GenericCow
is provided, which allows conversion from
certain pointers into an owned value though an .into_owned()
method. The
trait GenericCow
is implemented for:
&'a B where B: ToOwned
Cow<'a, B> where B: ToOwned
Owned<'a, B, O> where O: Borrow<B>
Here
B: ?Sized
is the borrowed type (and also the type of the pointer target) andO: Borrow<B>
is an owned type.
Changelog
- 2022-07-01: Version 0.5.0
- A lifetime and type argument for the borrowed type has been added to
Owned
, which now contains aPhantomData
of a reference to the borrowed type. This makesOwnedRef
superfluous, which has been removed. IntoOwned
has been renamed toGenericCow
.
- A lifetime and type argument for the borrowed type has been added to
- 2022-06-30: Version 0.4.0
- Removed implementations of
IntoOwned
forBox<T>
,Vec<T>
, andString
- New wrapper type
OwnedRef<T>
- Removed implementations of
- 2022-06-28: Version 0.3.0
- Added implementations of
IntoOwned
forBox<T>
(where T: ?Sized
),Vec<T>
, andString
, withIntoOwned::Owned
being set toSelf
(replaces previous implementation forBox<T>
)
- Added implementations of
- 2022-06-27: Version 0.2.0
- Some more trait implementations (
AsRef
,AsMut
,Borrow
,BorrowMut
, andDisplay
) have been added forOwned
(andDebug::fmt
's output is transparent now) Deref
is now a supertrait ofIntoOwned
andIntoOwned::Owned
must implementBorrow<<Self as Deref>::Target>
- Some more trait implementations (
- 2022-06-26: Version 0.1.0
- Initial release