News for hackers. Stuff that matters.
Re:Announcing Rust 1.13 by QuantumLogic on Thursday November 10, 2016 @04:41PM (#12924674)
I don't get why they'll let the language be abstracted in that way, but are against having ternary operators. It's the one thing that's somewhat bugged me about Rust. Aside from this one minor thing, I"ve been really loving the language itself.

    let greater = a < b ? b : a;
Is a lot better than having to write this all the time:

    let greater = if a < b { return a; } else { return b; };
Re:Announcing Rust 1.13 by masklinn on Thursday November 10, 2016 @04:45PM (#12924706)
But…. these are two completely different statements, the equivalent Rust is

    if a < b { b } else { a }
why are you adding sprurious returns? And if you need to get the minimum of two values so much that actually impacts you, write a `min!` macro?
Re:Announcing Rust 1.13 by shepmaster on Thursday November 10, 2016 @05:43PM (#12925249)
No macros needed!

    use std::cmp::min;
    min(a, b);
https://doc.rust-lang.org/std/cmp/fn.min.html
Re:Announcing Rust 1.13 by masklinn on Friday November 11, 2016 @04:47AM (#12929253)
Ha. I should have known, thanks.
Re:Announcing Rust 1.13 by steveklabnik on Thursday November 10, 2016 @04:43PM (#12924691)
This doesn't duplicate anything in the language; it moves a stdlib macro to be included in the core language.

Since if is an expression, ternay operators would be wholly redundant.

Re:Announcing Rust 1.13 by QuantumLogic on Thursday November 10, 2016 @04:46PM (#12924713)
The whole point of it would be to have a higher level of abstraction which makes codebases more concise. Avoiding duplication for the sake of avoiding it is as nonsensical as avoiding 100 dollar bills since we already have 100 single dollar bills that could make it up.
Re:Announcing Rust 1.13 by masklinn on Thursday November 10, 2016 @04:55PM (#12924803)
> The whole point of it would be to have a higher level of abstraction

What are you talking about? A ternary isn't a higher level of abstraction, it's at best the exact same thing with a different syntax, at worst it's a more limited version of the same.

Re:Announcing Rust 1.13 by Gankro on Thursday November 10, 2016 @06:21PM (#12925600)
I tip my hat to you for remaining committed to one of the oldest Rust trolls there is.
Re:Announcing Rust 1.13 by sixbrx on Thursday November 10, 2016 @06:18PM (#12925574)
Ditch the returns and semicolons in the latter, then if is your ternary op, just more readable in cases where a and b are expressions more complex than in this example.