| Crates.io | child-of |
| lib.rs | child-of |
| version | 1.0.3 |
| created_at | 2025-08-06 14:56:13.117379+00 |
| updated_at | 2025-08-07 08:16:16.042668+00 |
| description | The library that allows you to make one struct a child of another. |
| homepage | |
| repository | https://github.com/Denis535/Rust.Libraries/tree/main/child-of |
| max_upload_size | |
| id | 1783887 |
| size | 4,973 |
The library that allows you to make one struct a child of another.
The #[child_of(Base)] attribute clearly marks your struct as a child of a base struct and implicitly declares a private base field.
use crate::child_of::*;
struct Base {}
impl Base {
pub fn new() -> Base {
Base {}
}
}
#[child_of(Base)] This attribute marks the "Child" struct as a child of the "Base" struct.
struct Child {
base: Base, // This field is implicitly declared by the #[child_of(Base)] attribute.
}
impl Child {
pub fn new() -> Child {
Child {
base: Base::new(),
}
}
pub fn base(&self) -> &Base {
&self.base
}
pub fn base_mut(&mut self) -> &mut Base {
&mut self.base
}
}