| Crates.io | dynp |
| lib.rs | dynp |
| version | 0.1.12 |
| created_at | 2023-09-24 21:10:32.501128+00 |
| updated_at | 2023-10-08 23:01:19.450863+00 |
| description | Dynamic property system that emphasizes the use of the Newtype pattern. |
| homepage | |
| repository | https://github.com/chillin-capybara/dynp |
| max_upload_size | |
| id | 982179 |
| size | 22,596 |
A dynamic, type-safe property system that emphasizes the use of the Newtype pattern.
This library was ispired by the iZotope/glassproperties C++ library; big credits to the amazing authors of that library.
The following snipped should give you a basic idea what this library is about.
use dynp::PropertyCollection;
// define a custom property using the Newtype pattern
#[derive(Copy, Clone, Debug)]
struct CustomProperty(i32);
fn main() {
// create a new property collection
let mut collection = PropertyCollection::new();
// assign a new property
collection.assign(CustomProperty(42));
// get the property
match collection.get::<CustomProperty>() {
Some(prop) => {
println!("Property: {:?}", prop);
},
None => {
println!("Property does not exist");
}
};
}