NEEDED: Lints to check for useful trait implementations
⚓ Rust 📅 2025-10-29 👤 surdeus 👁️ 6Background
I recently was reading the book "Rust for Rustaceans" and found a part where it mentioned that it is generally a good idea to implement certain commonly useful traits on your types.
Even if you personally won't use one of those traits' functionality, there is a chance one of your API users will, and the Orphan Rule makes it hard for them to implement those traits on your types after the fact.
Useful traits
In this spirit, I have a list of traits I want to derive for my types (where compatible):
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
struct MyType {
// ...
}
This means I now have a list of 10 different traits that I want to start implementing more consistently in my projects.
I could just check manually, but that could get laborious and error-prone depending on the volume of code involved. I'd much rather automate the process of checking for this stuff.
Lints
I noticed there are lints to warn me when I am passing-up on opportunities to implement these useful traits, but I've only been able to find such lints for 2 of them: Copy and Debug:
#![warn(missing_copy_implementations)]
#![warn(missing_debug_implementations)]
What about the other useful traits out there? Is there anything I can do to also have lints set for them as well?
1 post - 1 participant
🏷️ Rust_feed