RS.CLIPPY.SHOULD_IMPLEMENT_TRAIT

Defining a method that should be implementing a std trait

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: should_implement_trait. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for methods that should live in a trait implementation of a std trait (see llogiq's blog post for further information) instead of an inherent implementation.

Why is this bad?

Implementing the traits improve ergonomics for users of the code, often with very little cost. Also people seeing a mul(...) method may expect * to work equally, so you should have good reason to disappoint them.

Example

struct X;
impl X {
    fn add(&self, other: &X) -> X {
        // ..
    }
}