assert_eq!(expected, actual) VS assert_eq!(actual, expected) (opens in new tab)

Discussed on r/rust

When an assert_eq! fails, you get a very generic "left VS right" message: assertion `left == right` failed left: "a" right: "b" This makes it hard to read output of failing tests if you're unsure whether the "expected" value is the "left" or the "right". I frequently come across Rust codebases that have a different order (actual VS expected OR expected VS actual), even in the same test module! A quick GitHub search shows: assert_eq!(expected, actual) is used 17,600 times assert_eq!(a...

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help