News for hackers. Stuff that matters.
Re:Why your first Rust FizzBuzz implementation may not work by chrismorgan on Sunday October 12, 2014 @10:51PM (#8447318)
It’s whether (i % 3, i % 5) is equal to (0, 0) et al., where _ means “any value”.
Re:Why your first Rust FizzBuzz implementation may not work by hoeppnertill on Monday October 13, 2014 @06:12AM (#8448132)
To be fair, you can bind to any name. So, binding to `a` instead of `_` would work as well. You could then use that bound value in the corresponding expression.

However, I would have expected rustc to complain about unused variables in

    fn main() {
        for i in range(1i, 101) {
            match (i % 3, i % 5) {
                (0, 0) => println!("Fizzbuzz"),
                (0, a) => println!("Fizz"),
                (b, 0) => println!("Buzz"),
                c => println!("{}", i),
            }
        }
    }
but neither the playpen nor yesterdays snapshot complains. And if you want to suppress warnings about unused variables, you prefix the variable with an underscore, or just use only the underscore, which got common to mean "I don't care what value gets bound to this name.".

    fn main() { let a = 0u; }
compiles with warning: unused variable: `a`, but

    fn main() { let _a = 0u; }
compiles silently.
Re:Why your first Rust FizzBuzz implementation may not work by dbaupp on Monday October 13, 2014 @07:59AM (#8448342)
Thanks for noticing that! I filed https://github.com/rust-lang/rust/issues/17999
Re:Why your first Rust FizzBuzz implementation may not work by sillysaurus3 on Sunday October 12, 2014 @10:59PM (#8447334)
That's a very useful feature. Maybe I'll go ahead and learn Rust now. If it has a features like pattern matching, which seems about ten times more useful than the classic switch statement, then it probably has a lot of other insights worth learning.

If you were to start a hypothetical project written in Rust, what would it be? I'm looking for something to cut my teeth on.

Re:Why your first Rust FizzBuzz implementation may not work by yen223 on Sunday October 12, 2014 @11:37PM (#8447393)
I would suggest you port over a project that you are already familiar with. It's easier to learn a new syntax when you don't have to grapple with implementation as well. And you get to have an objective comparison of the same project implemented 2 different ways.
Re:Why your first Rust FizzBuzz implementation may not work by steveklabnik on Monday October 13, 2014 @02:36AM (#8447711)
I agree with this, but I will say that sometimes, you end up structuring a program differently due to the language. This happens a lot in Rust.

It's still easier when you've solved the problem previously, however.