Skip to main content

GenericGeneration

Trait GenericGeneration 

Source
pub trait GenericGeneration {
    // Required methods
    fn from_untyped_generation(generation: Generation) -> Self
       where Self: Sized;
    fn into_untyped_generation(self) -> Generation
       where Self: Sized;
    fn as_untyped_generation(&self) -> &Generation;
}
Expand description

A trait abstracting over typed and untyped generation numbers.

This can be used to write code that’s generic over TypedGeneration, Generation, and other types that may wrap TypedGeneration (due to e.g. orphan rules).

This trait is similar to From, but a bit harder to get wrong – in general, the conversion from and to untyped generation numbers should be careful and explicit.

Required Methods§

Source

fn from_untyped_generation(generation: Generation) -> Self
where Self: Sized,

Creates a new instance of Self from an untyped Generation.

Source

fn into_untyped_generation(self) -> Generation
where Self: Sized,

Converts self into an untyped Generation.

Source

fn as_untyped_generation(&self) -> &Generation

Returns the inner Generation.

Generally, into_untyped_generation should be preferred. However, in some cases it may be necessary to use this method to satisfy lifetime constraints.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§