Daily downloads in decline
Bruno Medeiros via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jun 12 04:55:32 PDT 2015
On 11/06/2015 18:48, Dennis Ritchie wrote:
> On Thursday, 11 June 2015 at 17:41:49 UTC, Andrei Alexandrescu wrote:
>>> It is possible that Walter and Andrei against macro because of this:
>>>
>>> macro_rules! o_O {
>>> (
>>> $(
>>> $x:expr; [ $( $y:expr ),* ]
>>> );*
>>> ) => {
>>> &[ $($( $x + $y ),*),* ]
>>> }
>>> }
>>>
>>> fn main() {
>>> let a: &[i32]
>>> = o_O!(10; [1, 2, 3];
>>> 20; [4, 5, 6]);
>>>
>>> assert_eq!(a, [11, 12, 13, 24, 25, 26]);
>>> }
>>>
>>> It looks disgusting! ;)
>>
>> Is that actual Rust code that compiles and runs? -- Andrei
>
> Yes, this code is working. I took it here:
> https://doc.rust-lang.org/stable/book/macros.html#repetition
OMG, and it's not just an obscure example someone came up with, but
actually a snippet from the official documentation!
That said, it does look a bit less crazy when looking at it with the
syntax highlighting.
--
Bruno Medeiros
https://twitter.com/brunodomedeiros
More information about the Digitalmars-d
mailing list