pub trait Collection {
type Entry;
type Val;
// Required method
fn entry_to_val(e: Self::Entry) -> Self::Val;
}Expand description
Represents a collection by defining the types of entries and values it handles.
This trait abstracts the nature of collections in data structures, facilitating the handling of contained
entries and values, especially in scenarios where the structure of the collection allows for complex relationships,
such as HashMaps. It not only identifies what constitutes an entry and a value in the context of the collection
but also provides utility for converting between these two, which is critical in operations involving entry manipulation
and value retrieval.
Required Associated Types§
Required Methods§
Sourcefn entry_to_val(e: Self::Entry) -> Self::Val
fn entry_to_val(e: Self::Entry) -> Self::Val
Converts an entry to its corresponding value within the collection. This function is essential for abstracting the collection’s internal representation from the values it manipulates.
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.