Borrowed

Struct Borrowed 

Source
pub struct Borrowed<'b, B: ?Sized>(pub &'b B);
Expand description

A StaticCow implementation which wraps an immutable reference.

Tuple Fields§

§0: &'b B

Trait Implementations§

Source§

impl<'b, B: ?Sized> AsRef<B> for Borrowed<'b, B>

Source§

fn as_ref(&self) -> &B

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'b, B: ?Sized> Borrow<B> for Borrowed<'b, B>

Source§

fn borrow(&self) -> &B

Immutably borrows from an owned value. Read more
Source§

impl<'b, B: Debug + ?Sized> Debug for Borrowed<'b, B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'b, B: ?Sized> Deref for Borrowed<'b, B>

Source§

type Target = B

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'b, B: Hash + ?Sized> Hash for Borrowed<'b, B>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'b, B> IntoOwning for Borrowed<'b, B>
where B: ToOwning + ?Sized,

Source§

fn into_owning(self) -> Self::Owning

Converts an object which owns its contents into one which borrows them.
Source§

impl<'b, B: Ord + ?Sized> Ord for Borrowed<'b, B>

Source§

fn cmp(&self, other: &Borrowed<'b, B>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'b, B: PartialEq + ?Sized> PartialEq for Borrowed<'b, B>

Source§

fn eq(&self, other: &Borrowed<'b, B>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'b, B: PartialOrd + ?Sized> PartialOrd for Borrowed<'b, B>

Source§

fn partial_cmp(&self, other: &Borrowed<'b, B>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'b, B> StaticCow<B> for Borrowed<'b, B>
where B: ToOwned + ?Sized,

Source§

fn is_owned(&self) -> bool

Returns true iff the data is owned, i.e. if self.into_owning() would be a no-op.
Source§

fn mut_if_owned(&mut self) -> MutIfOwned<'_, <Self as Deref>::Target>

Returns either an immutable reference to an object that is borrowed, or a mutable reference to one which is owned. Read more
Source§

fn into_cow<'a>(self) -> Cow<'a, B>
where Self: 'a, Self::Owning: 'a,

Converts self into its dynamic equivalent as a Cow.
Source§

fn into_owned(self) -> B::Owned

Converts self into a B::Owned, cloning only if necessary.
Source§

fn is_borrowed(&self) -> bool

Returns true iff the data is borrowed, i.e. if self.into_owning() would clone it.
Source§

impl<'b, B> ToOwning for Borrowed<'b, B>
where B: ToOwning + ?Sized,

Source§

type Owning = Owned<B>

The resulting type after obtaining ownership of self’s contents.
Source§

fn to_owning(&self) -> Self::Owning

Creates an object which owns its contents from one which borrows them.
Source§

impl<'b, B: Eq + ?Sized> Eq for Borrowed<'b, B>

Source§

impl<'b, B: ?Sized> StructuralPartialEq for Borrowed<'b, B>

Auto Trait Implementations§

§

impl<'b, B> Freeze for Borrowed<'b, B>
where B: ?Sized,

§

impl<'b, B> RefUnwindSafe for Borrowed<'b, B>
where B: RefUnwindSafe + ?Sized,

§

impl<'b, B> Send for Borrowed<'b, B>
where B: Sync + ?Sized,

§

impl<'b, B> Sync for Borrowed<'b, B>
where B: Sync + ?Sized,

§

impl<'b, B> Unpin for Borrowed<'b, B>
where B: ?Sized,

§

impl<'b, B> UnwindSafe for Borrowed<'b, B>
where B: RefUnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.