Open
Description
As pointed out in rust-lang/rust#42998 it's an anti-pattern in Rust to create a tuple struct and then used named accessors, as in:
/// Type for Unicode Version.
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct UnicodeVersion(
pub u16, // Major version
pub u16, // Minor version
pub u16 // Micro (or Update) version
);
impl UnicodeVersion {
/// Major version
pub fn major(&self) -> u16 {
self.0
}
/// Minor version
pub fn minor(&self) -> u16 {
self.1
}
/// Micro (or Update) version
pub fn micro(&self) -> u16 {
self.2
}
}
We should lint cases like this and suggest replacing the tuple struct with a named-field struct, and adding a new
method instead.