File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -352,6 +352,13 @@ pub trait Extend<A> {
352
352
fn extend < T : IntoIterator < Item =A > > ( & mut self , iter : T ) ;
353
353
}
354
354
355
+ #[ stable( feature = "extend_for_unit" , since = "1.28.0" ) ]
356
+ impl Extend < ( ) > for ( ) {
357
+ fn extend < T : IntoIterator < Item = ( ) > > ( & mut self , iter : T ) {
358
+ iter. into_iter ( ) . for_each ( drop)
359
+ }
360
+ }
361
+
355
362
/// An iterator able to yield elements from both ends.
356
363
///
357
364
/// Something that implements `DoubleEndedIterator` has one extra capability
Original file line number Diff line number Diff line change
1
+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ pub fn main ( ) {
12
+ let mut x = 0 ;
13
+ {
14
+ let iter = ( 0 ..5 ) . map ( |_| {
15
+ x += 1 ;
16
+ } ) ;
17
+ ( ) . extend ( iter) ;
18
+ }
19
+ assert_eq ! ( x, 5 ) ;
20
+ }
You can’t perform that action at this time.
0 commit comments