4 ms·
That seems like an odd decision? It's like saying there is no consensus for which side of the road to drive on, so let's not pick one. Standardization is arbitr
by skybrian 8y ago
That seems like an odd decision? It's like saying there is no consensus for which side of the road to drive on, so let's not pick one. Standardization is arbitrary but useful here.
- steveklabnik 8y agoThe best argument for picking a specific side was the comment below about "expected, actual" vs "these two things are not equal." In the end, we decided that this just wasn't enough of a benefit to justify making an arbitrary choice. If we did choose, a lot of code would have to change, as existing Rust codebases also used both conventions. Rust already forces the user to follow a lot of rules; this one just wasn't deemed worth it.
- coldtea 8y agoHow is it useful, since it has no observable effect? Equals is equals!
- skybrian 8y agoAs many people pointed out, an expected value is not the same as the actual value. This affects error messages, which are important for ergonomics.
- eridius 8y agoThe downside to enforcing an order is the compiler cannot enforce an order so people absolutely will get it wrong and not notice until much later when the test breaks and they get really confused because the message is telling them the expected value is the actual value and vice versa.
- tomjakubowski 8y agoWe could have a macro like: test_eq!(expected=(<expr>), actual=(<expr>)); Where those "assignments" could be specified in either order. Playground example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a4142e215dfb46ebfdab447ec22b6b95 https://play.rust-lang.org/?version=stable&mode=debug&editio...
- xixixao 8y agoI really like this, not that I would want to write this every time, but because you could have a macro rule that doesn't specify expected/actual, for those rare cases where both sides are computed ("actual").