UniqueVersioned

Trait UniqueVersioned 

Source
pub trait UniqueVersioned: Versioned {
    // Required methods
    fn as_unique_version(&self) -> &Self::LatestVersion;
    fn as_unique_version_mut(&mut self) -> &mut Self::LatestVersion;
    fn into_unique_version(self) -> Self::LatestVersion;
    fn from_unique_version(unique_version: Self::LatestVersion) -> Self;
}
Expand description

A trait for Versioned types which only have a single version.

This enables a number of special-cased methods to be implemented which are only possible when there is only one version.

Required Methods§

Source

fn as_unique_version(&self) -> &Self::LatestVersion

Returns an immutable reference to (currently) the only possible version of the inner content.

Source

fn as_unique_version_mut(&mut self) -> &mut Self::LatestVersion

Returns a mutable reference to (currently) the only possible version of the inner content.

This is somewhat equivalent to in_place_fully_update_and_as_latest_version_mut, but doesn’t need to do any updating, so can be used where logical correctness requires there to be a unique version, requires no updating, or simply for slightly better performance.

Source

fn into_unique_version(self) -> Self::LatestVersion

Returns the (currently) only possible version of the inner content.

This is somewhat equivalent to fully_update_and_into_latest_version, but doesn’t need to do any updating, so can be used where logical correctness requires there to be a unique version, requires no updating, or simply for slightly better performance.

Source

fn from_unique_version(unique_version: Self::LatestVersion) -> Self

Creates the versioned wrapper from the (currently) only possible version.

This is equivalent to from_latest_version, but useful to use instead if your logic’s correctness is dependent on there only being a single version. If another version gets added, this method will give a compile error.

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.

Implementors§