As for the pointer dereferencing, perhaps putting the type there will make it clearer:
[1, 2, 3].map(|x: &int| if *x > max { max = *x });
Now you can see that x isn't actually an int but a reference to one.
As for automatically derived traits, those are actually slightly more powerful macros implemented in the compiler itself. You can see it at rust/src/libsyntax/ext/*.
For default methods, you just put the code you want in the trait itself. Like so:
The make_sound method is what's called a default method. If you implemented that trait, at the very least you would have to define the sound method and if you wanted to, you could override the default make_sound method.
As for the pointer dereferencing, perhaps putting the type there will make it clearer:
Now you can see that x isn't actually an int but a reference to one.As for automatically derived traits, those are actually slightly more powerful macros implemented in the compiler itself. You can see it at rust/src/libsyntax/ext/*.
For default methods, you just put the code you want in the trait itself. Like so:
The make_sound method is what's called a default method. If you implemented that trait, at the very least you would have to define the sound method and if you wanted to, you could override the default make_sound method.Macros are actually created with another macro called macro_rules. I'll defer to the tutorial for them: http://static.rust-lang.org/doc/0.8/tutorial-macros.html