pub trait AsIs: Sized + Borrow<Self::Is> {
type Is: ?Sized + ToOwned;
fn as_is<'a>(self) -> Is<'a, Self::Is>
where
Self: 'a;
fn borrow_or_clone<B: ?Sized>(&self) -> IsCow<'_, B>
where
Self::Is: Borrow<B>,
Owned<Self>: Borrow<B>,
B: ToOwned<Owned = Owned<Self>>,
{ ... }
fn into_is<'a, B: ?Sized>(self) -> Is<'a, B>
where
Self: 'a,
Self::Is: BorrowMut<B>,
B: ToOwned<Owned = Owned<Self>>,
{ ... }
fn into_is_cow<'a, B: ?Sized>(self) -> IsCow<'a, B>
where
Self: 'a,
Self::Is: Borrow<B>,
B: ToOwned<Owned = Owned<Self>>,
{ ... }
fn try_into_is_mut<'a, B: ?Sized>(
self
) -> Result<IsMut<'a, B>, Is<'a, Self::Is>>
where
Self: 'a,
Self::Is: BorrowMut<B>,
B: ToOwned<Owned = Owned<Self>>,
{ ... }
fn try_into_owned<'a>(self) -> Result<Owned<Self>, Is<'a, Self::Is>>
where
Self: 'a,
{ ... }
fn into_cow<'a, B: ?Sized>(self) -> Cow<'a, B>
where
Self: 'a,
Self::Is: Borrow<B>,
B: ToOwned<Owned = Owned<Self>> + ToOwned<Owned = Owned<Self>>,
{ ... }
}Expand description
Used to do a cheap conversion into Is<'a, T> in a generic context.
Required Associated Types
Required Methods
sourcefn as_is<'a>(self) -> Is<'a, Self::Is>where
Self: 'a,
fn as_is<'a>(self) -> Is<'a, Self::Is>where
Self: 'a,
Converts self into an Is<'a, Self::Is>.
Provided Methods
sourcefn borrow_or_clone<B: ?Sized>(&self) -> IsCow<'_, B>where
Self::Is: Borrow<B>,
Owned<Self>: Borrow<B>,
B: ToOwned<Owned = Owned<Self>>,
fn borrow_or_clone<B: ?Sized>(&self) -> IsCow<'_, B>where
Self::Is: Borrow<B>,
Owned<Self>: Borrow<B>,
B: ToOwned<Owned = Owned<Self>>,
Immutably borrows from self by default, but can be overridden to clone self if
appropriate.
sourcefn into_is<'a, B: ?Sized>(self) -> Is<'a, B>where
Self: 'a,
Self::Is: BorrowMut<B>,
B: ToOwned<Owned = Owned<Self>>,
fn into_is<'a, B: ?Sized>(self) -> Is<'a, B>where
Self: 'a,
Self::Is: BorrowMut<B>,
B: ToOwned<Owned = Owned<Self>>,
Converts self into an Is<'a, B>.
sourcefn into_is_cow<'a, B: ?Sized>(self) -> IsCow<'a, B>where
Self: 'a,
Self::Is: Borrow<B>,
B: ToOwned<Owned = Owned<Self>>,
fn into_is_cow<'a, B: ?Sized>(self) -> IsCow<'a, B>where
Self: 'a,
Self::Is: Borrow<B>,
B: ToOwned<Owned = Owned<Self>>,
Converts self into an IsCow<'a, B>.
sourcefn try_into_is_mut<'a, B: ?Sized>(
self
) -> Result<IsMut<'a, B>, Is<'a, Self::Is>>where
Self: 'a,
Self::Is: BorrowMut<B>,
B: ToOwned<Owned = Owned<Self>>,
fn try_into_is_mut<'a, B: ?Sized>(
self
) -> Result<IsMut<'a, B>, Is<'a, Self::Is>>where
Self: 'a,
Self::Is: BorrowMut<B>,
B: ToOwned<Owned = Owned<Self>>,
Converts self into an IsMut<'a, B> without cloning if possible.
Errors
If self cannot be converted without cloning, returns self as is.