Skip to content

make type modifiers usable for macro substitution #5748

Closed
@metajack

Description

@metajack

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

    A-syntaxextArea: Syntax extensions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions