child-of

Crates.iochild-of
lib.rschild-of
version1.0.3
created_at2025-08-06 14:56:13.117379+00
updated_at2025-08-07 08:16:16.042668+00
descriptionThe library that allows you to make one struct a child of another.
homepage
repositoryhttps://github.com/Denis535/Rust.Libraries/tree/main/child-of
max_upload_size
id1783887
size4,973
Denis (Denis535)

documentation

README

Overview

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.

Example

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
    }
}

Links

Commit count: 0

cargo fmt