operator
Rust ==: test equality
Use `==` to test whether two values compare equal. It produces a Boolean, not an assignment. Expected output (not executed): true blue Why: The strings have equal contents and the comparison does not consume either String. Common mistake: Use `==`, not `=`, when testing equality. NaN is not equal to itself. Advanced connection: `std::cmp::PartialEq::eq`; comparison borrows operands implicitly.
Formal Syntax & Structure
rust syntaxrust
a == bWorking Example
Example Snippetrust
fn main() { let entered = String::from("blue"); let expected = String::from("blue"); println!("{}", entered == expected); println!("{entered}");}