pub trait CollectionRef: Collection {
type ItemRef<'a>: Clone + Deref<Target = Self::Item>
where Self: 'a;
// Required method
fn upcast_item_ref<'short, 'long: 'short>(
r: Self::ItemRef<'long>,
) -> Self::ItemRef<'short>
where Self: 'long;
}Expand description
Abstract collection that can be immutably referenced.
Required Associated Types§
Required Methods§
Sourcefn upcast_item_ref<'short, 'long: 'short>(
r: Self::ItemRef<'long>,
) -> Self::ItemRef<'short>where
Self: 'long,
fn upcast_item_ref<'short, 'long: 'short>(
r: Self::ItemRef<'long>,
) -> Self::ItemRef<'short>where
Self: 'long,
Changes an item reference into a shorter lived reference.
Item references are covariant with
regard to the defined lifetime parameter 'a.
Since this cannot be directly expressed by the type system, this associated function
allows one to explicitly shorten the reference’s lifetime.
You can use the covariant_item_ref! macro to automatically
implement this function.
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.