Intentions to change `assert(a == b)` to `assert_eq(a, b)`
See original GitHub issueThere are handy assert_eq
, assert_ne
macros in Rust. It would be nice to have inspections which would highlightassert!(a == b)
and assert!(a != b)
and suggest to change them into assert_eq(a, b)
and assert_ne!(a, b)
.
A similar inspection is implemented here: https://github.com/intellij-rust/intellij-rust/blob/master/src/main/kotlin/org/rust/ide/inspections/RsSimplifyPrintInspection.kt
A complete example of adding new inspections is here: https://github.com/intellij-rust/intellij-rust/commit/df64cbac9b6d14413bd15f3e33971ea725108a1e#diff-5e7848624647a9a96dd649e15fa64ae5
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Python's assert: Debug and Test Your Code Like a Pro
In this tutorial, you'll learn how to use Python's assert statement to document, debug, and test code in development.
Read more >Python Assert Statement - Programiz
In this article we will learn about assertion in Python using assert. What is Assertion? Assertions are statements that assert or state a...
Read more >unittest — Unit testing framework — Python 3.11.1 ...
The crux of each test is a call to assertEqual() to check for an expected result; ... There is less temptation to change...
Read more >What is the use of "assert" in Python? - Stack Overflow
The assert statement exists in almost every programming language. It has two main uses: It helps detect problems early in your program, ...
Read more >Assertion assertNotEquals Provides Wrong Error Message On ...
Failed asserting that 'a b c' is not equal to 'a b c'. ... And it produces an unexpected error message that it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Note that our plugin is often used by beginner rustaceans, and so this intention might encourage them to use pattern which soon will be deprecated.
Note that recently an RFC was accepted that makes
assert!(a == b)
the preferred form in the future: RFC 2011 Nicer assert messagesSo I would consider undoing the warning about using
assert!
, to not make people switch toassert_eq!
and then back when the betterassert!
is implemented.