Crates.io | deref_owned |
lib.rs | deref_owned |
version | 0.10.2 |
source | src |
created_at | 2022-06-26 08:11:17.148975 |
updated_at | 2022-07-12 14:32:19.795654 |
description | Generalization of std::borrow::Cow |
homepage | |
repository | |
max_upload_size | |
id | 613442 |
size | 14,581 |
Generalization of std::borrow::Cow
, which can be used to reduce runtime
overhead in certain scenarios.
#[repr(transparent)]
to Owned
wrapperOwned
. This allows specifying the borrowed type as an associated type of
the GenericCow
trait, which aids type inference.From
for Owned
had to be removed.From<T>
for Owned<T>
From<T>
for Owned<T>
AsRef<U>
for Owned<T>
and implement
AsRef<T>
only (this is to allow going from Owned<T>
to T
where T: !AsRef<T>
) (Yanked because .borrow()
should be used in
that case.)Owned
is now a simple wrapper with one type argument (of its
inner value).Owned::new
has been removed.GenericCow<B>::Owned
has been removed in favor of
using <B as ToOwned>::Owned
.Deref
as supertrait of GenericCow
and added type argument to
GenericCow
insteadOwned::borrowed
to be
PhantomData<for<'a> fn(&'a O) -> &'a B>
instead of using
PhantomData<*const B>
, which broke correct autotrait behaviorOwned
Owned
, which now contains a PhantomData
of a reference to the
borrowed type. This makes OwnedRef
superfluous, which has been removed.IntoOwned
has been renamed to GenericCow
.AsMut
, BorrowMut
and DerefMut
implementations for Owned
IntoOwned
for Box<T>
, Vec<T>
, and
String
OwnedRef<T>
IntoOwned
for Box<T>
(where T: ?Sized
),
Vec<T>
, and String
, with IntoOwned::Owned
being set to Self
(replaces previous implementation for Box<T>
)AsRef
, AsMut
, Borrow
, BorrowMut
,
and Display
) have been added for Owned
(and Debug::fmt
's output is transparent now)Deref
is now a supertrait of IntoOwned
and IntoOwned::Owned
must
implement Borrow<<Self as Deref>::Target>