Struct resman::Entry

source ·
pub struct Entry<'a, R> { /* private fields */ }

Implementations§

An entry to a resource container.

This is similar to the Entry API found in the standard library.

Examples
use rt_map::RtMap;

#[derive(Debug)]
struct Res(i32);

let mut rt_map = RtMap::<u32, Res>::default();

let value = rt_map.entry(0).or_insert(Res(4));
println!("{:?}", value.0 * 2);

Create new entry.

Returns this entry’s value, inserts and returns v otherwise.

Please note that you should use or_insert_with in case the creation of the value is expensive.

Returns this entry’s value, inserts and returns the return value of f otherwise.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.