RS.CLIPPY.NEEDLESS_ARBITRARY_SELF_TYPE
Type of `self` parameter is already by default `Self`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: needless_arbitrary_self_type. Copyright ©2025 The Rust Team. All rights reserved.
What it does
The lint checks for self in fn parameters that
specify the Self-type explicitly
Why is this bad?
Increases the amount and decreases the readability of code
Example
enum ValType {
I32,
I64,
F32,
F64,
}
impl ValType {
pub fn bytes(self: Self) -> usize {
match self {
Self::I32 | Self::F32 => 4,
Self::I64 | Self::F64 => 8,
}
}
}
Could be rewritten as
enum ValType {
I32,
I64,
F32,
F64,
}
impl ValType {
pub fn bytes(self) -> usize {
match self {
Self::I32 | Self::F32 => 4,
Self::I64 | Self::F64 => 8,
}
}
}