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