2

Does Rust have any equivalent to

x = a ? b : c;

I would guess someone could write a macro that writes out

    if a { 
        b 
    } else { 
        c 
    }

maybe in a crate somewhere, if not in core?

x = a | b;

would be useful as well with C assumptions for truth being non zero.

(I'm porting Java, seems Rust is a lot more verbose even than Java)

Christophe
  • 68,716
  • 7
  • 72
  • 138
teknopaul
  • 6,505
  • 2
  • 30
  • 24
  • 4
    *I'm porting Java, seems Rust is a lot more verbose even than Java* — writing Java in Rust is likely more verbose than writing Java in Java. My guess is that writing Rust in Rust is equally or less verbose than Java in Java. – Shepmaster Sep 17 '19 at 17:06
  • *maybe in a crate somewhere* — FYI, questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow. – Shepmaster Sep 17 '19 at 17:07

0 Answers0