3 #![warn(clippy::manual_map)]
8 clippy::match_ref_pats,
9 clippy::redundant_pattern_matching,
16 Some(0).map(|x| x + 1);
18 Some("").map(|x| x.is_empty());
23 Some(0).map(std::convert::identity);
25 Some(&String::new()).map(|x| str::len(x));
28 Some(x) if false => Some(x + 1),
32 Some([0, 1]).as_ref().map(|x| x[0]);
34 Some(0).map(|x| x * 2);
36 Some(String::new()).as_ref().map(|x| x.is_empty());
38 Some(String::new()).as_ref().map(|x| x.len());
40 Some(0).map(|x| x + x);
42 #[warn(clippy::option_map_unit_fn)]
43 match &mut Some(String::new()) {
44 Some(x) => Some(x.push_str("")),
48 #[allow(clippy::option_map_unit_fn)]
50 Some(String::new()).as_mut().map(|x| x.push_str(""));
53 Some(String::new()).as_ref().map(|x| x.len());
55 Some(String::new()).as_ref().map(|x| x.is_empty());
57 Some((0, 1, 2)).map(|(x, y, z)| x + y + z);
59 Some([1, 2, 3]).map(|[first, ..]| first);
61 Some((String::new(), "test")).as_ref().map(|(x, y)| (y, x));
63 match Some((String::new(), 0)) {
64 Some((ref x, y)) => Some((y, x)),
69 Some(Some(_)) | Some(None) => Some(0),
73 match Some(Some((0, 1))) {
74 Some(Some((x, 1))) => Some(x),
79 fn f1() -> Result<(), ()> {
80 let _ = match Some(Ok(())) {
87 for &x in Some(Some(true)).iter() {
89 Some(x) => Some(if x { continue } else { x }),
95 let x1 = (Some(String::new()), 0);
98 Some(x) => Some((x, x1.1)),
107 fn f(self) -> Option<(String, u32)> {
109 Some(x) => Some((x, self.y)),
116 Some(0).map(|x| vec![x]);
118 option_env!("").map(String::from);
121 async fn f2(x: u32) -> u32 {
127 Some(x) => Some(f2(x).await),
133 if let Some(_) = Some(0) {
135 } else { Some(0).map(|x| x + 1) };
139 } else { Some(0).map(|x| x + 1) };
144 Some(x) => Some(x + 1),
150 let s = &String::new();
151 let _: Option<&str> = match Some(s) {