Skip to content

Trouble with using item macros to create methods inside impls #4641

New issue

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

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

Already on GitHub? # to your account

Closed
brendanzab opened this issue Jan 26, 2013 · 2 comments
Closed

Trouble with using item macros to create methods inside impls #4641

brendanzab opened this issue Jan 26, 2013 · 2 comments

Comments

@brendanzab
Copy link
Member

macro_rules! static_methods {
    { $($t:ty :: $id:ident () -> $ret:expr);+ } => {
        $(static fn $id () -> $t { $ret })+
    }
}

type MyInt = int;

impl MyInt {
    static_methods! {
        MyInt::zero()  -> 0;
        MyInt::one()   -> 1;
        MyInt::life()  -> 42;
    }
}

fn main() {}
macro-in-impl.rs:10:4: 10:18 error: unexpected token: `static_methods`
macro-in-impl.rs:10     static_methods! {
@catamorphism
Copy link
Contributor

Yeah, this isn't supported right now, but #4621 requests it.

@catamorphism
Copy link
Contributor

Closing as a dup. But this is one more vote for #4621 :-)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants