]> git.lizzy.rs Git - rust.git/blob - tests/ui/wrong_self_conventions_mut.rs
Auto merge of #7047 - camsteffen:lang-ctor, r=flip1995
[rust.git] / tests / ui / wrong_self_conventions_mut.rs
1 // edition:2018
2 #![warn(clippy::wrong_self_convention)]
3 #![allow(dead_code)]
4
5 fn main() {}
6
7 mod issue6758 {
8     pub enum Test<T> {
9         One(T),
10         Many(Vec<T>),
11     }
12
13     impl<T> Test<T> {
14         // If a method starts with `to_` and not ends with `_mut` it should expect `&self`
15         pub fn to_many(&mut self) -> Option<&mut [T]> {
16             match self {
17                 Self::Many(data) => Some(data),
18                 _ => None,
19             }
20         }
21
22         // If a method starts with `to_` and ends with `_mut` it should expect `&mut self`
23         pub fn to_many_mut(&self) -> Option<&[T]> {
24             match self {
25                 Self::Many(data) => Some(data),
26                 _ => None,
27             }
28         }
29     }
30 }