{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreia2comi4ckbmzbelmuypt3kfnrr4iqfhhnjtj3vcjkptshr5zncrm",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mibfzti5d772"
  },
  "path": "/t/change-error-message-of-a-failing-assert-eq/24118#post_1",
  "publishedAt": "2026-03-30T07:37:31.000Z",
  "site": "https://internals.rust-lang.org",
  "tags": [
    "17,600 times",
    "32,800 times"
  ],
  "textContent": "When an `assert_eq!` fails, you get a very generic \"left VS right\" message:\n\n\n    assertion `left == right` failed\n      left: \"a\"\n     right: \"b\"\n\n\nThis makes it hard to read output of failing tests if you're unsure whether the \"expected\" value is the \"left\" or the \"right\".\n\nI _frequently_ come across Rust codebases that have a different order (**actual VS expected** OR **expected VS actual**), even in the same test module!\n\nA quick GitHub search shows:\n\n  * `assert_eq!(expected, actual)` is used 17,600 times\n  * `assert_eq!(actual, expected)` is used 32,800 times\n\n\n\nI think there's a lot of value to gain in eliminating this inconsistency from the ecosystem, to have an actual idiom of the order of \"actual VS expected\" or \"expected VS actual\" in assertions.\n\nBecause the \"actual VS expected\" case reads more naturally, and because it is also the most common, I propose changing the error message of a failing `assert_eq!` to \"actual VS expected\":\n\n\n    assertion `actual == expected` failed\n       actual: \"a\"\n     expected: \"b\"\n",
  "title": "Change error message of a failing `assert_eq!`"
}