Files
rust/tests/ui/wrong_self_conventions_mut.rs

34 lines
809 B
Rust
Raw Normal View History

#![warn(clippy::wrong_self_convention)]
#![allow(dead_code)]
fn main() {}
mod issue6758 {
pub enum Test<T> {
One(T),
Many(Vec<T>),
}
impl<T> Test<T> {
// If a method starts with `to_` and not ends with `_mut` it should expect `&self`
pub fn to_many(&mut self) -> Option<&mut [T]> {
2025-02-12 23:44:38 +01:00
//~^ wrong_self_convention
2025-02-11 17:57:08 +01:00
match self {
Self::Many(data) => Some(data),
_ => None,
}
}
// If a method starts with `to_` and ends with `_mut` it should expect `&mut self`
pub fn to_many_mut(&self) -> Option<&[T]> {
2025-02-12 23:44:38 +01:00
//~^ wrong_self_convention
2025-02-11 17:57:08 +01:00
match self {
Self::Many(data) => Some(data),
_ => None,
}
}
}
}