Skip to content

AmbientTea/rust-delegate-trait

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Delegate Trait

This crate provides traits and macros that implement the delegation pattern for traits.

Minimal example

#[delegated]
pub trait MyTrait {
    fn do_stuff(&self) -> String;
}

struct A;
impl MyTrait for A {
    fn do_stuff(&self) -> String {
        "Hello there!".into()
    }
}

struct B {
    a: A
}
delegate_field!(a: A as MyTrait for B)

About

Low-boilerplate delegation for user-controlled traits

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages