AsIs

Trait AsIs 

Source
pub trait AsIs: Sized + BorrowAsIs {
    // Required method
    fn as_is<'a>(self) -> Is<'a, Self::Is>
       where Self: 'a;

    // Provided methods
    fn into_is<'a, B>(self) -> Is<'a, B>
       where Self: 'a,
             Self::Is: BorrowMut<B>,
             B: ?Sized + ToOwned<Owned = Owned<Self>> { ... }
    fn into_is_cow<'a, B>(self) -> IsCow<'a, B>
       where Self: 'a,
             Self::Is: Borrow<B>,
             B: ?Sized + ToOwned<Owned = Owned<Self>> { ... }
    fn try_into_is_mut<'a, B>(self) -> Result<IsMut<'a, B>, Is<'a, Self::Is>>
       where Self: 'a,
             Self::Is: BorrowMut<B>,
             B: ?Sized + 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>(self) -> Cow<'a, B>
       where Self: 'a,
             Self::Is: Borrow<B>,
             B: ?Sized + ToOwned<Owned = Owned<Self>> { ... }
}
Expand description

Used to do a cheap conversion into Is<'a, T> in generic contexts.

Required Methods§

Source

fn as_is<'a>(self) -> Is<'a, Self::Is>
where Self: 'a,

Converts self into an Is<'a, Self::Is>.

Provided Methods§

Source

fn into_is<'a, B>(self) -> Is<'a, B>
where Self: 'a, Self::Is: BorrowMut<B>, B: ?Sized + ToOwned<Owned = Owned<Self>>,

Converts self into an Is<'a, B>.

Source

fn into_is_cow<'a, B>(self) -> IsCow<'a, B>
where Self: 'a, Self::Is: Borrow<B>, B: ?Sized + ToOwned<Owned = Owned<Self>>,

Converts self into an IsCow<'a, B>.

Source

fn try_into_is_mut<'a, B>(self) -> Result<IsMut<'a, B>, Is<'a, Self::Is>>
where Self: 'a, Self::Is: BorrowMut<B>, B: ?Sized + 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<'a, Self::Is>.

Source

fn try_into_owned<'a>(self) -> Result<Owned<Self>, Is<'a, Self::Is>>
where Self: 'a,

Converts self into an owned data without cloning if possible.

§Errors

If self cannot be converted without cloning, returns self as Is<'a, Self::Is>.

Source

fn into_cow<'a, B>(self) -> Cow<'a, B>
where Self: 'a, Self::Is: Borrow<B>, B: ?Sized + ToOwned<Owned = Owned<Self>>,

Converts self into a Cow<'a, B>. Only available if the alloc feature is enabled.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl AsIs for bool

Source§

fn as_is<'a>(self) -> Is<'a, bool>

Source§

impl AsIs for f32

Source§

fn as_is<'a>(self) -> Is<'a, f32>

Source§

impl AsIs for f64

Source§

fn as_is<'a>(self) -> Is<'a, f64>

Source§

impl AsIs for i8

Source§

fn as_is<'a>(self) -> Is<'a, i8>

Source§

impl AsIs for i16

Source§

fn as_is<'a>(self) -> Is<'a, i16>

Source§

impl AsIs for i32

Source§

fn as_is<'a>(self) -> Is<'a, i32>

Source§

impl AsIs for i64

Source§

fn as_is<'a>(self) -> Is<'a, i64>

Source§

impl AsIs for i128

Source§

fn as_is<'a>(self) -> Is<'a, i128>

Source§

impl AsIs for isize

Source§

fn as_is<'a>(self) -> Is<'a, isize>

Source§

impl AsIs for u8

Source§

fn as_is<'a>(self) -> Is<'a, u8>

Source§

impl AsIs for u16

Source§

fn as_is<'a>(self) -> Is<'a, u16>

Source§

impl AsIs for u32

Source§

fn as_is<'a>(self) -> Is<'a, u32>

Source§

impl AsIs for u64

Source§

fn as_is<'a>(self) -> Is<'a, u64>

Source§

impl AsIs for u128

Source§

fn as_is<'a>(self) -> Is<'a, u128>

Source§

impl AsIs for usize

Source§

fn as_is<'a>(self) -> Is<'a, usize>

Source§

impl AsIs for String

Source§

fn as_is<'a>(self) -> Is<'a, Self>

Source§

impl<T> AsIs for Cow<'_, T>
where T: ?Sized + BorrowAsIs<Is = T> + ToOwned,

Source§

fn as_is<'a>(self) -> Is<'a, T>
where Self: 'a,

Source§

impl<T> AsIs for &T
where Self: Borrow<T::Is>, T: ?Sized + BorrowAsIs,

Source§

fn as_is<'a>(self) -> Is<'a, T::Is>
where Self: 'a,

Source§

impl<T> AsIs for &mut T
where Self: Borrow<T::Is>, T: ?Sized + BorrowMutAsIs,

Source§

fn as_is<'a>(self) -> Is<'a, T::Is>
where Self: 'a,

Source§

impl<T> AsIs for Vec<T>
where T: Clone,

Source§

fn as_is<'a>(self) -> Is<'a, Self>

Implementors§

Source§

impl<T> AsIs for Is<'_, T>
where T: ?Sized + BorrowAsIs<Is = T> + ToOwned,

Source§

impl<T> AsIs for IsCow<'_, T>
where T: ?Sized + BorrowAsIs<Is = T> + ToOwned,

Source§

impl<T> AsIs for IsMut<'_, T>
where T: ?Sized + BorrowAsIs<Is = T> + ToOwned,