Skip to content

make type modifiers usable for macro substitution #285

Closed
@rust-highfive

Description

@rust-highfive

Issue by metajack
Friday Apr 05, 2013 at 21:04 GMT

For earlier discussion, see rust-lang/rust#5748

This issue was labelled with: A-syntaxext, B-RFC in the Rust repository


Currently you can not pass @ or ~ or @mut to a macro by itself, but this would be useful in a few cases. I tried doing this to add Clone trait implementations without copying the code:

macro_rules! ptr_clone_impl(
    ($p:something) => {
        impl<T:Clone> Clone for $p T {
            #[inline(always)]
            fn clone(&self) -> $p T { $p (**self).clone() }
        }
    }
)

ptr_clone_impl!(~)
ptr_clone_impl!(@)
ptr_clone_impl!(@mut)

But as far as I can tell there is no fragment specifier that will work for those tokens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions