Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example use cases #13

Open
nikomatsakis opened this issue May 25, 2017 · 1 comment
Open

example use cases #13

nikomatsakis opened this issue May 25, 2017 · 1 comment

Comments

@nikomatsakis
Copy link
Owner

It'd be great to accumulate more use-cases.

Open thread for suggestions. =)

@nielsle
Copy link

nielsle commented May 25, 2018

Delegation traits (Code stolen from EddyB)

// Potentially somewhere central, or generated per-trait.
trait Delegate/*Health*/ {
    type Delegatee;
    delegatee: Self::Delegatee;
}
impl<T: Delegate/*Health*/> Health for T
    where T::Delegatee: Health
{
    fn health(&self) -> u8 {
        self.delegatee.health()
    }
}
impl Delegate/*Health*/ for Player {
    delegatee => self.health;
}

rust-lang/rfcs#2393 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants