Skip to main content

IntoView

Trait IntoView 

Source
pub trait IntoView<'msg>: SealedInternal + AsView {
    // Required method
    fn into_view<'shorter>(self) -> View<'shorter, Self::Proxied>
       where 'msg: 'shorter;
}
Expand description

Used to turn another ‘borrow’ into a view proxy.

On a mut proxy this borrows to a View (semantically matching turning a &mut T into a &T).

On a view proxy this will behave as a reborrow into a shorter lifetime (semantically matching a &'a T into a &'b T where 'a: 'b).

Required Methods§

Source

fn into_view<'shorter>(self) -> View<'shorter, Self::Proxied>
where 'msg: 'shorter,

Converts into a View with a potentially shorter lifetime.

In non-generic code we don’t need to use into_view because the proxy types are covariant over 'msg. However, generic code conservatively treats 'msg as invariant, therefore we need to call into_view to explicitly perform the operation that in concrete code coercion would perform implicitly.

fn reborrow_generic_view_into_view<'a, 'b, T>(
    x: View<'a, T>,
    y: View<'b, T>,
) -> [View<'b, T>; 2]
where
    T: MutProxied,
    'a: 'b,
{
    // `[x, y]` fails to compile because `'a` is not the same as `'b` and the `View`
    // lifetime parameter is (conservatively) invariant.
    // `[x.as_view(), y]` fails because that borrow cannot outlive `'b`.
    [x.into_view(), y]
}

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<'msg> IntoView<'msg> for &'msg [u8]

Source§

fn into_view<'shorter>(self) -> &'shorter [u8]
where 'msg: 'shorter,

Source§

impl<'msg> IntoView<'msg> for bool

Source§

fn into_view<'shorter>(self) -> bool
where 'msg: 'shorter,

Source§

impl<'msg> IntoView<'msg> for f32

Source§

fn into_view<'shorter>(self) -> f32
where 'msg: 'shorter,

Source§

impl<'msg> IntoView<'msg> for f64

Source§

fn into_view<'shorter>(self) -> f64
where 'msg: 'shorter,

Source§

impl<'msg> IntoView<'msg> for i32

Source§

fn into_view<'shorter>(self) -> i32
where 'msg: 'shorter,

Source§

impl<'msg> IntoView<'msg> for i64

Source§

fn into_view<'shorter>(self) -> i64
where 'msg: 'shorter,

Source§

impl<'msg> IntoView<'msg> for u32

Source§

fn into_view<'shorter>(self) -> u32
where 'msg: 'shorter,

Source§

impl<'msg> IntoView<'msg> for u64

Source§

fn into_view<'shorter>(self) -> u64
where 'msg: 'shorter,

Source§

impl<'msg, T: Proxied> IntoView<'msg> for &'msg T

Source§

fn into_view<'shorter>(self) -> View<'shorter, T>
where 'msg: 'shorter,

Source§

impl<'msg, T: Proxied> IntoView<'msg> for &'msg mut T

Source§

fn into_view<'shorter>(self) -> View<'shorter, T>
where 'msg: 'shorter,

Implementors§

Source§

impl<'msg> IntoView<'msg> for &'msg ProtoStr

Source§

impl<'msg> IntoView<'msg> for ProtoBytesCow<'msg>

Source§

impl<'msg> IntoView<'msg> for ProtoStringCow<'msg>

Source§

impl<'msg, K: MapKey, V: MapValue> IntoView<'msg> for MapMut<'msg, K, V>

Source§

impl<'msg, K: MapKey, V: MapValue> IntoView<'msg> for MapView<'msg, K, V>

Source§

impl<'msg, T: Singular> IntoView<'msg> for RepeatedMut<'msg, T>

Source§

impl<'msg, T: Singular> IntoView<'msg> for RepeatedView<'msg, T>