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§
Sourcefn into_view<'shorter>(self) -> View<'shorter, Self::Proxied>where
'msg: 'shorter,
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.