resources

This crate provides the Resources
struct:
a container that stores at most one value of each specific type,
and allows safely and concurrently accessing any of them with interior mutability,
without violating borrow rules.
It's intended to be used as an implementation of storage for data that is not
associated with any specific entity in an ECS (entity component system),
but still needs concurrent access by systems.
use resources::*;
struct SomeNumber(usize);
struct SomeString(&'static str);
fn main() {
let mut resources = Resources::new();
resources.insert(SomeNumber(4));
resources.insert(SomeString("Hello!"));
let resources = resources;
{
let mut some_number = resources.get_mut::<SomeNumber>().unwrap();
let mut some_string = resources.get_mut::<SomeNumber>().unwrap();
assert!(resources.get::<SomeNumber>().is_err());
some_number.0 = 2;
some_string.0 = "Bye!";
}
assert_eq!(resources.get::<SomeNumber>().0, 2);
let some_string1 = resources.get::<SomeString>().unwrap();
let some_string2 = resources.get::<SomeString>().unwrap();
assert_eq!(some_string1.0, some_string2.0);
}