🗂️ resman
Runtime managed resource borrowing.
This library provides a map that can store one of any type, as well as mutable borrows to each type at the same time.
Note: This implementation is extracted from shred
, with the following differences:
- Uses
downcast-rs
instead ofmopa
for downcasting types. - Adds
Debug
andPartialEq
implementations for borrow types when the resource type implements those traits. - Returns
None
instead of panicking fortry_borrow*
functions when the resource is already borrowed.
Usage
Add the following to Cargo.toml
= "0.6.0"
# or
= { = "0.6.0", = ["debug"] }
In code:
use Resources;
;
;
Features
-
"debug"
:The
Debug
implementation forResources
will use theDebug
implementation for the values when printed. This requires that allResources
to also implementDebug
.Given the following:
let mut resources = default; resources.insert; println!;
Without
"debug"
feature:With
"debug"
feature:
See Also
anymap
: Map of any type, without multiple mutable borrows.shred
: ContainsResources
type, plus a task dispatcher.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.