@@ -1180,26 +1180,27 @@ pub trait Iterator {
11801180 ///
11811181 /// // this iterator sequence is complex.
11821182 /// let sum = a.iter()
1183- /// .cloned()
1184- /// .filter(|& x| x % 2 == 0)
1185- /// .fold(0, |sum, i| sum + i);
1183+ /// .cloned()
1184+ /// .filter(|x| x % 2 == 0)
1185+ /// .fold(0, |sum, i| sum + i);
11861186 ///
11871187 /// println!("{}", sum);
11881188 ///
11891189 /// // let's add some inspect() calls to investigate what's happening
11901190 /// let sum = a.iter()
1191- /// .cloned()
1192- /// .inspect(|x| println!("about to filter: {}", x))
1193- /// .filter(|& x| x % 2 == 0)
1194- /// .inspect(|x| println!("made it through filter: {}", x))
1195- /// .fold(0, |sum, i| sum + i);
1191+ /// .cloned()
1192+ /// .inspect(|x| println!("about to filter: {}", x))
1193+ /// .filter(|x| x % 2 == 0)
1194+ /// .inspect(|x| println!("made it through filter: {}", x))
1195+ /// .fold(0, |sum, i| sum + i);
11961196 ///
11971197 /// println!("{}", sum);
11981198 /// ```
11991199 ///
12001200 /// This will print:
12011201 ///
12021202 /// ```text
1203+ /// 6
12031204 /// about to filter: 1
12041205 /// about to filter: 4
12051206 /// made it through filter: 4
@@ -1230,8 +1231,7 @@ pub trait Iterator {
12301231 ///
12311232 /// let iter = a.into_iter();
12321233 ///
1233- /// let sum: i32 = iter.take(5)
1234- /// .fold(0, |acc, &i| acc + i );
1234+ /// let sum: i32 = iter.take(5).fold(0, |acc, i| acc + i );
12351235 ///
12361236 /// assert_eq!(sum, 6);
12371237 ///
@@ -1245,9 +1245,7 @@ pub trait Iterator {
12451245 /// let mut iter = a.into_iter();
12461246 ///
12471247 /// // instead, we add in a .by_ref()
1248- /// let sum: i32 = iter.by_ref()
1249- /// .take(2)
1250- /// .fold(0, |acc, &i| acc + i );
1248+ /// let sum: i32 = iter.by_ref().take(2).fold(0, |acc, i| acc + i );
12511249 ///
12521250 /// assert_eq!(sum, 3);
12531251 ///
@@ -1304,9 +1302,7 @@ pub trait Iterator {
13041302 ///
13051303 /// let a = [1, 2, 3];
13061304 ///
1307- /// let doubled: VecDeque<i32> = a.iter()
1308- /// .map(|&x| x * 2)
1309- /// .collect();
1305+ /// let doubled: VecDeque<i32> = a.iter().map(|&x| x * 2).collect();
13101306 ///
13111307 /// assert_eq!(2, doubled[0]);
13121308 /// assert_eq!(4, doubled[1]);
@@ -1318,9 +1314,7 @@ pub trait Iterator {
13181314 /// ```
13191315 /// let a = [1, 2, 3];
13201316 ///
1321- /// let doubled = a.iter()
1322- /// .map(|&x| x * 2)
1323- /// .collect::<Vec<i32>>();
1317+ /// let doubled = a.iter().map(|x| x * 2).collect::<Vec<i32>>();
13241318 ///
13251319 /// assert_eq!(vec![2, 4, 6], doubled);
13261320 /// ```
@@ -1331,9 +1325,7 @@ pub trait Iterator {
13311325 /// ```
13321326 /// let a = [1, 2, 3];
13331327 ///
1334- /// let doubled = a.iter()
1335- /// .map(|&x| x * 2)
1336- /// .collect::<Vec<_>>();
1328+ /// let doubled = a.iter().map(|x| x * 2).collect::<Vec<_>>();
13371329 ///
13381330 /// assert_eq!(vec![2, 4, 6], doubled);
13391331 /// ```
@@ -1344,9 +1336,9 @@ pub trait Iterator {
13441336 /// let chars = ['g', 'd', 'k', 'k', 'n'];
13451337 ///
13461338 /// let hello: String = chars.iter()
1347- /// .map(|&x| x as u8)
1348- /// .map(|x| (x + 1) as char)
1349- /// .collect();
1339+ /// .map(|&x| x as u8)
1340+ /// .map(|x| (x + 1) as char)
1341+ /// .collect();
13501342 ///
13511343 /// assert_eq!("hello", hello);
13521344 /// ```
@@ -1393,8 +1385,9 @@ pub trait Iterator {
13931385 /// ```
13941386 /// let a = [1, 2, 3];
13951387 ///
1396- /// let (even, odd): (Vec<i32>, Vec<i32>) = a.into_iter()
1397- /// .partition(|&n| n % 2 == 0);
1388+ /// let (even, odd): (Vec<i32>, Vec<i32>) = a
1389+ /// .into_iter()
1390+ /// .partition(|&n| n % 2 == 0);
13981391 ///
13991392 /// assert_eq!(even, vec![2]);
14001393 /// assert_eq!(odd, vec![1, 3]);
@@ -1457,8 +1450,7 @@ pub trait Iterator {
14571450 /// let a = [1, 2, 3];
14581451 ///
14591452 /// // the checked sum of all of the elements of the array
1460- /// let sum = a.iter()
1461- /// .try_fold(0i8, |acc, &x| acc.checked_add(x));
1453+ /// let sum = a.iter().try_fold(0i8, |acc, &x| acc.checked_add(x));
14621454 ///
14631455 /// assert_eq!(sum, Some(6));
14641456 /// ```
@@ -1556,8 +1548,7 @@ pub trait Iterator {
15561548 /// let a = [1, 2, 3];
15571549 ///
15581550 /// // the sum of all of the elements of the array
1559- /// let sum = a.iter()
1560- /// .fold(0, |acc, &x| acc + x);
1551+ /// let sum = a.iter().fold(0, |acc, x| acc + x);
15611552 ///
15621553 /// assert_eq!(sum, 6);
15631554 /// ```
0 commit comments