pub trait AnyStorage: Default + 'static {
type Ref<'a, T: ?Sized + 'static>: Deref<Target = T>;
type Mut<'a, T: ?Sized + 'static>: DerefMut<Target = T>;
// Required methods
fn downcast_lifetime_ref<'a: 'b, 'b, T: ?Sized + 'static>(
ref_: Self::Ref<'a, T>,
) -> Self::Ref<'b, T>;
fn downcast_lifetime_mut<'a: 'b, 'b, T: ?Sized + 'static>(
mut_: Self::Mut<'a, T>,
) -> Self::Mut<'b, T>;
fn try_map_mut<T: ?Sized + 'static, U: ?Sized + 'static>(
mut_ref: Self::Mut<'_, T>,
f: impl FnOnce(&mut T) -> Option<&mut U>,
) -> Option<Self::Mut<'_, U>>;
fn try_map<T: ?Sized, U: ?Sized + 'static>(
ref_: Self::Ref<'_, T>,
f: impl FnOnce(&T) -> Option<&U>,
) -> Option<Self::Ref<'_, U>>;
fn data_ptr(&self) -> *const ();
fn recycle(location: GenerationalPointer<Self>);
// Provided methods
fn map_mut<T: ?Sized + 'static, U: ?Sized + 'static>(
mut_ref: Self::Mut<'_, T>,
f: impl FnOnce(&mut T) -> &mut U,
) -> Self::Mut<'_, U> { ... }
fn map<T: ?Sized, U: ?Sized + 'static>(
ref_: Self::Ref<'_, T>,
f: impl FnOnce(&T) -> &U,
) -> Self::Ref<'_, U> { ... }
fn owner() -> Owner<Self> { ... }
}
Expand description
A trait for any storage backing type.
Required Associated Types§
Required Methods§
Sourcefn downcast_lifetime_ref<'a: 'b, 'b, T: ?Sized + 'static>(
ref_: Self::Ref<'a, T>,
) -> Self::Ref<'b, T>
fn downcast_lifetime_ref<'a: 'b, 'b, T: ?Sized + 'static>( ref_: Self::Ref<'a, T>, ) -> Self::Ref<'b, T>
Downcast a reference in a Ref to a more specific lifetime
This function enforces the variance of the lifetime parameter 'a
in Ref. Rust will typically infer this cast with a concrete type, but it cannot with a generic type.
Sourcefn downcast_lifetime_mut<'a: 'b, 'b, T: ?Sized + 'static>(
mut_: Self::Mut<'a, T>,
) -> Self::Mut<'b, T>
fn downcast_lifetime_mut<'a: 'b, 'b, T: ?Sized + 'static>( mut_: Self::Mut<'a, T>, ) -> Self::Mut<'b, T>
Downcast a mutable reference in a RefMut to a more specific lifetime
This function enforces the variance of the lifetime parameter 'a
in Mut. Rust will typically infer this cast with a concrete type, but it cannot with a generic type.
Sourcefn try_map_mut<T: ?Sized + 'static, U: ?Sized + 'static>(
mut_ref: Self::Mut<'_, T>,
f: impl FnOnce(&mut T) -> Option<&mut U>,
) -> Option<Self::Mut<'_, U>>
fn try_map_mut<T: ?Sized + 'static, U: ?Sized + 'static>( mut_ref: Self::Mut<'_, T>, f: impl FnOnce(&mut T) -> Option<&mut U>, ) -> Option<Self::Mut<'_, U>>
Try to map the mutable ref.
Sourcefn try_map<T: ?Sized, U: ?Sized + 'static>(
ref_: Self::Ref<'_, T>,
f: impl FnOnce(&T) -> Option<&U>,
) -> Option<Self::Ref<'_, U>>
fn try_map<T: ?Sized, U: ?Sized + 'static>( ref_: Self::Ref<'_, T>, f: impl FnOnce(&T) -> Option<&U>, ) -> Option<Self::Ref<'_, U>>
Try to map the ref.
Sourcefn data_ptr(&self) -> *const ()
fn data_ptr(&self) -> *const ()
Get the data pointer. No guarantees are made about the data pointer. It should only be used for debugging.
Sourcefn recycle(location: GenerationalPointer<Self>)
fn recycle(location: GenerationalPointer<Self>)
Recycle a memory location. This will drop the memory location and return it to the runtime.
Provided Methods§
Sourcefn map_mut<T: ?Sized + 'static, U: ?Sized + 'static>(
mut_ref: Self::Mut<'_, T>,
f: impl FnOnce(&mut T) -> &mut U,
) -> Self::Mut<'_, U>
fn map_mut<T: ?Sized + 'static, U: ?Sized + 'static>( mut_ref: Self::Mut<'_, T>, f: impl FnOnce(&mut T) -> &mut U, ) -> Self::Mut<'_, U>
Map the mutable ref.
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.