1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Dynamic property system that emphasizes the use of the Newtype pattern.
//!
//! Each property must be represented by a unique type. This allows the compiler to
//! check the type of each property at compile time and provide a type-safe way of using dynamic
//! properties.
//!
//! # Example
//!
//! ```
//! 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");
//! }
//! };
//! }
//! ```
//!
pub use PropertyCollection;