pub trait ValToEntry<Collection> {
type Entry;
// Required method
fn val_to_entry(self) -> Self::Entry;
}
Expand description
Facilitates the conversion of values back into entries for specific collection types.
This trait wraps the functionality of CollectionValToEntry
, providing a more ergonomic
interface for converting values directly within the type they pertain to. It is useful
in maintaining the integrity of collection operations, especially when dealing with
sophisticated structures that separate the concept of values and entries, such as HashMap
s
and other associative collections.
Required Associated Types§
Required Methods§
Sourcefn val_to_entry(self) -> Self::Entry
fn val_to_entry(self) -> Self::Entry
Transforms the instance (value) into an entry compatible with the specified collection. This conversion is essential for operations like insertion or modification within the collection, where the value needs to be formatted as an entry.
§Returns
Returns the entry constructed from the instance of the value, ready for integration into the collection.
§Example
use former_types::ValToEntry; // use crate `former` instead of crate `former_types` unless you need to use crate `former_types` directly
struct PairMap;
impl ValToEntry< PairMap > for (i32, i32)
{
type Entry = ( String, i32 );
fn val_to_entry( self ) -> Self::Entry
{
(self.0.to_string(), self.1)
}
}