Struct shred::Entry [] [src]

pub struct Entry<'a, T: 'a> { /* fields omitted */ }

An entry to a resource of the Resources struct. This is similar to the Entry API found in the standard library.

Examples

use shred::Resources;

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

let mut res = Resources::new();

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

Methods

impl<'a, T> Entry<'a, T> where
    T: Resource + 'a, 
[src]

[src]

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.

[src]

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

Trait Implementations

Auto Trait Implementations

impl<'a, T> !Send for Entry<'a, T>

impl<'a, T> !Sync for Entry<'a, T>