]> git.lizzy.rs Git - rust.git/blob - tests/ui/match_single_binding2.fixed
Auto merge of #7007 - Y-Nak:result_unit_err, r=giraffate
[rust.git] / tests / ui / match_single_binding2.fixed
1 // run-rustfix
2
3 #![warn(clippy::match_single_binding)]
4 #![allow(unused_variables)]
5
6 fn main() {
7     // Lint (additional curly braces needed, see #6572)
8     struct AppendIter<I>
9     where
10         I: Iterator,
11     {
12         inner: Option<(I, <I as Iterator>::Item)>,
13     }
14
15     #[allow(dead_code)]
16     fn size_hint<I: Iterator>(iter: &AppendIter<I>) -> (usize, Option<usize>) {
17         match &iter.inner {
18             Some((iter, _item)) => {
19                 let (min, max) = iter.size_hint();
20                 (min.saturating_add(1), max.and_then(|max| max.checked_add(1)))
21             },
22             None => (0, Some(0)),
23         }
24     }
25
26     // Lint (no additional curly braces needed)
27     let opt = Some((5, 2));
28     let get_tup = || -> (i32, i32) { (1, 2) };
29     match opt {
30         #[rustfmt::skip]
31         Some((first, _second)) => {
32             let (a, b) = get_tup();
33             println!("a {:?} and b {:?}", a, b);
34         },
35         None => println!("nothing"),
36     }
37 }