macro

assert_ne! — Check two values are different

Require two values to compare unequal under PartialEq; suitable Debug implementations are needed to report failures. This is a useful test of an expected difference, not a proof of global uniqueness. Expression result: (). Expected result (not executed): stdout: 'Distinct IDs\n'; no stderr. Common mistake: Treating one pairwise comparison as proof that an entire collection has unique IDs.

Formal Syntax & Structure

rust syntaxrust
assert_ne!(left, right) or assert_ne!(left, right, "message", arguments...)

Working Example

Example Snippetrust
fn main() {    let old_id = 17;    let new_id = 18;    assert_ne!(old_id, new_id);    println!("Distinct IDs");}
Rust Reference