E0369
Rust Programming Language
Severity: ModerateWhat it means
You used an operator like + - or == on a type that does not support it.
Rust operators are backed by traits — your type must implement the right trait.
Implement the trait or use a method instead of the operator.
Affected Models
- Rust stable
- Rust nightly
- Cargo build
- Rust 2021 edition
Common Causes
- Using + on a custom struct without implementing the Add trait
- Using == on a type that does not implement PartialEq
- Using < or > on a type that does not implement PartialOrd
- Using * or / on a type that does not implement Mul or Div
- Trying to negate a value with - on a type that does not implement Neg
How to Fix It
-
Identify which operator you used and which trait it requires.
+ requires Add, == requires PartialEq, < requires PartialOrd, * requires Mul.
The error message names the missing trait. -
Derive the trait automatically if your type is simple and all its fields already implement it.
Add #[derive(PartialEq, PartialOrd)] above your struct or enum.
This works when all fields support the same trait. -
Implement the trait manually for custom comparison or arithmetic logic.
Example: impl Add for MyType { type Output = MyType; fn add(self, other: MyType) -> MyType { ... } }
-
If you just need equality checks, derive PartialEq and Eq together.
#[derive(PartialEq, Eq)] handles == and != for most types.
Use Eq when equality is always total (no NaN cases). -
If you do not want to implement the trait, use a method instead of the operator.
Instead of a + b, write a.add_to(b) where add_to is a method you define on your type.
When to Call a Professional
E0369 is safe to fix yourself by implementing the required trait.
For complex types in a large codebase, review whether operator overloading is the right design choice.
Frequently Asked Questions
Why does Rust require a trait for operators instead of just allowing them?
Rust's operators are syntactic sugar for trait method calls.
+ calls Add::add(), == calls PartialEq::eq().
This design lets any type opt into operator support while keeping the type system consistent.
What is the difference between PartialEq and Eq?
PartialEq allows some values to be incomparable — like floating-point NaN, which is not equal to itself.
Eq is a stronger guarantee: every value of the type is comparable to every other.
Most types should derive both; float types only get PartialEq.
Can I overload operators for types I did not write?
No — Rust's orphan rules prevent implementing a trait for a type if neither the trait nor the type is defined in your crate.
This prevents conflicting implementations across libraries.
Use a newtype wrapper to work around this: struct MyVec(Vec