-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-syntaxextArea: Syntax extensionsArea: Syntax extensions
Description
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
Labels
A-syntaxextArea: Syntax extensionsArea: Syntax extensions
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
bstrie commentedon May 28, 2013
I know that @pcwalton has been interested in making
~
and@
act just like any other type, so perhaps this is worth supporting (assuming that user-defined types would normally be valid in this context).pnkfelix commentedon May 28, 2013
~
and@
are type-constructors, not types, no? (Still, it might be sense to add support for them to the macro-system. I.e. have some way to pass around thesetype -> type
operators.)catamorphism commentedon Aug 5, 2013
Bug triage: doesn't look like a release blocker to me.
emberian commentedon Jan 6, 2014
cc @jbclements
I feel like this is tricky, although it shouldn't be too hard for just the sigils.
emberian commentedon Jul 29, 2014
Now that we have
box
and have removed those other types, this doesn't make quite as much sense. Once box itself infers the boxed-type this shouldn't be necessary. What's missing is to be able to have something like type level functions... I haveBox
, I want to apply it toT
to getBox<T>
, but our syntax doesn't really make that convenient.Just some scattered thoughts..
rust-highfive commentedon Sep 24, 2014
This issue has been moved to the RFCs repo: rust-lang/rfcs#285
Auto merge of rust-lang#5748 - carols10cents:tiny-docs-fix, r=flip1995