Last active
December 26, 2015 21:38
-
-
Save tomassedovic/7217029 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[feature(macro_rules)]; | |
struct Object; | |
impl Object { | |
pub fn is_blue(&self) -> bool {true} | |
pub fn is_small(&self) -> bool {true} | |
pub fn is_heavy(&self) -> bool {true} | |
} | |
macro_rules! is( | |
($object:ident, $($property:ident),+) => ( | |
($($object.concat_idents!(is_, $property))&&*) | |
) | |
) | |
fn main() { | |
let obj = Object; | |
// should be expanded to: (obj.is_blue() && obj.is_small() && obj.is_heavy()) | |
if is!(obj, blue, small, heavy) {} | |
// macros.rs:14:32: 14:33 error: expected one of `,`, `)` but found `!` | |
// macros.rs:14 ($($object.concat_idents!(is_, $property)),*) | |
// ^ | |
// task '<unnamed>' failed at 'explicit failure', /home/thomas/opt/code/rust/src/libsyntax/diagnostic.rs:75 | |
// task '<unnamed>' failed at 'explicit failure', /home/thomas/opt/code/rust/src/librustc/rustc.rs:396 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment