> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rust Inequality

The `!=` (not equal to) operator is a binary comparison operator that evaluates to `true` if its two operands are not equivalent, and `false` otherwise. It serves as syntactic sugar for the `ne` method defined in the `std::cmp::PartialEq` trait.

```rust theme={"dark"}
fn main() {
    let a = 5;
    let b = 10;
    let is_not_equal = a != b; // Evaluates to true
}
```

## Trait Resolution and Desugaring

In Rust, operators are backed by the trait system. The `!=` operator requires the left-hand operand's type to implement `PartialEq<Rhs>`, where `Rhs` is the type of the right-hand operand.

When the compiler encounters the `!=` operator, it implicitly borrows both operands and desugars the expression into a method call:

```rust theme={"dark"}
fn main() {
    let a = 5;
    let b = 10;

    // Standard syntax
    let result_standard = a != b;

    // Desugared compiler equivalent
    let result_desugared = std::cmp::PartialEq::ne(&a, &b);
}
```

## The `PartialEq` Trait Mechanics

The behavior of `!=` is dictated by the `PartialEq` trait definition in the standard library:

```rust theme={"dark"}
pub trait PartialEq<Rhs = Self>
where
    Rhs: ?Sized,
{
    fn eq(&self, other: &Rhs) -> bool;

    // Default implementation for !=
    fn ne(&self, other: &Rhs) -> bool {
        !self.eq(other)
    }
}
```

Because `ne` provides a default implementation that strictly returns the logical negation of `eq`, custom types typically only need to implement the `eq` method. The `!=` operator will then automatically utilize this default `ne` method implementation without requiring any procedural macro derivation or manual implementation of the inequality logic.

## Technical Characteristics

* **Ownership and Borrowing:** The `!=` operator evaluates operands by reference (`&self` and `&other`). It does not consume, move, or mutate the underlying values.
* **Type Coercion:** Rust does not perform implicit type coercion during comparison. Attempting to use `!=` on variables of different types will result in a compile-time type error, unless a specific `PartialEq<TypeB>` implementation exists for `TypeA`.
* **Floating-Point Behavior:** Because floating-point numbers (`f32`, `f64`) implement `PartialEq` rather than `Eq` (due to IEEE 754 standards), comparing `f32::NAN != f32::NAN` evaluates to `true`. This occurs because `NaN` lacks the reflexive property (`f32::NAN == f32::NAN` is `false`), and the `ne` method strictly negates the result of `eq`.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Rust Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
