[−][src]Struct left_right::aliasing::Aliased
A T
that is aliased.
You should be able to mostly ignore this type, as it can generally be treated exactly like a
&T
. However, there are some minor exceptions around forwarding traits -- since Aliased
is a
wrapper type around T
, it cannot automatically forward traits it does not know about to &T
.
This means that if your &T
implements, say, Serialize
or some custom Borrow<Q>
,
Aliased<T>
will not implement that same trait. You can work around this either by
implementing your trait specifically for Aliased<T>
where possible, or by manually
dereferencing to get the &T
before using the trait.
Implementations
impl<T, D> Aliased<T, D> where
D: DropBehavior,
[src]
D: DropBehavior,
pub unsafe fn alias(&self) -> Self
[src]
Create an alias of the inner T
.
Safety
This method is only safe to call as long as you ensure that the alias is never used after
an Aliased<T, D>
of self
where D::DO_DROP
is true
is dropped, and as long
as no &mut T
is ever given out while some Aliased<T>
may still be used. The returned
type assumes that it is always safe to dereference into &T
, which would not be true if
either of those invariants were broken.
pub fn from(t: T) -> Self
[src]
Construct an aliased value around a T
.
This method is safe since it effectively leaks T
. Note that we do not implement From<T>
because we do not want users to construct Aliased<T>
s on their own. If they did, they
would almost certain end up with incorrect drop behavior.
pub unsafe fn change_drop<D2: DropBehavior>(self) -> Aliased<T, D2>
[src]
Turn this aliased T
into one with a different drop behavior.
Safety
It is always safe to change an Aliased
from a dropping D
to a non-dropping D
. Going
the other way around is only safe if self
is the last alias for the T
.
Trait Implementations
impl<T, D> AsRef<T> for Aliased<T, D> where
D: DropBehavior,
[src]
D: DropBehavior,
impl<T, D> Borrow<[T]> for Aliased<Vec<T>, D> where
D: DropBehavior,
[src]
D: DropBehavior,
impl<D> Borrow<Path> for Aliased<PathBuf, D> where
D: DropBehavior,
[src]
D: DropBehavior,
impl<T, D> Borrow<T> for Aliased<T, D> where
D: DropBehavior,
[src]
D: DropBehavior,
impl<T, D> Borrow<T> for Aliased<Box<T>, D> where
T: ?Sized,
D: DropBehavior,
[src]
T: ?Sized,
D: DropBehavior,
impl<T, D> Borrow<T> for Aliased<Arc<T>, D> where
T: ?Sized,
D: DropBehavior,
[src]
T: ?Sized,
D: DropBehavior,
impl<T, D> Borrow<T> for Aliased<Rc<T>, D> where
T: ?Sized,
D: DropBehavior,
[src]
T: ?Sized,
D: DropBehavior,
impl<D> Borrow<str> for Aliased<String, D> where
D: DropBehavior,
[src]
D: DropBehavior,
impl<T, D> Debug for Aliased<T, D> where
D: DropBehavior,
T: Debug,
[src]
D: DropBehavior,
T: Debug,
impl<T, D> Deref for Aliased<T, D> where
D: DropBehavior,
[src]
D: DropBehavior,
impl<T, D> Drop for Aliased<T, D> where
D: DropBehavior,
[src]
D: DropBehavior,
impl<T, D> Eq for Aliased<T, D> where
D: DropBehavior,
T: Eq,
[src]
D: DropBehavior,
T: Eq,
impl<T, D> Hash for Aliased<T, D> where
D: DropBehavior,
T: Hash,
[src]
D: DropBehavior,
T: Hash,
pub fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T, D> Ord for Aliased<T, D> where
D: DropBehavior,
T: Ord,
[src]
D: DropBehavior,
T: Ord,
pub fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<T, D> PartialEq<Aliased<T, D>> for Aliased<T, D> where
D: DropBehavior,
T: PartialEq,
[src]
D: DropBehavior,
T: PartialEq,
pub fn eq(&self, other: &Self) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T, D> PartialOrd<Aliased<T, D>> for Aliased<T, D> where
D: DropBehavior,
T: PartialOrd,
[src]
D: DropBehavior,
T: PartialOrd,
pub fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
pub fn lt(&self, other: &Self) -> bool
[src]
pub fn le(&self, other: &Self) -> bool
[src]
pub fn gt(&self, other: &Self) -> bool
[src]
pub fn ge(&self, other: &Self) -> bool
[src]
impl<T, D> Send for Aliased<T, D> where
D: DropBehavior,
T: Send + Sync,
[src]
D: DropBehavior,
T: Send + Sync,
impl<T, D> Sync for Aliased<T, D> where
D: DropBehavior,
T: Sync,
[src]
D: DropBehavior,
T: Sync,
Auto Trait Implementations
impl<T, D> RefUnwindSafe for Aliased<T, D> where
D: RefUnwindSafe,
T: RefUnwindSafe,
[src]
D: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, D> Unpin for Aliased<T, D> where
D: Unpin,
T: Unpin,
[src]
D: Unpin,
T: Unpin,
impl<T, D> UnwindSafe for Aliased<T, D> where
D: UnwindSafe,
T: RefUnwindSafe + UnwindSafe,
[src]
D: UnwindSafe,
T: RefUnwindSafe + UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,