File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -288,3 +288,10 @@ impl<E:CLike> Extend<E> for EnumSet<E> {
288
288
}
289
289
}
290
290
}
291
+
292
+ #[ unstable( feature = "extend_ref" , reason = "recently added" ) ]
293
+ impl < ' a , E : ' a + CLike + Copy > Extend < & ' a E > for EnumSet < E > {
294
+ fn extend < I : IntoIterator < Item =& ' a E > > ( & mut self , iter : I ) {
295
+ self . extend ( iter. into_iter ( ) . cloned ( ) ) ;
296
+ }
297
+ }
Original file line number Diff line number Diff line change @@ -242,3 +242,25 @@ fn test_overflow() {
242
242
let mut set = EnumSet :: new ( ) ;
243
243
set. insert ( Bar :: V64 ) ;
244
244
}
245
+
246
+ #[ test]
247
+ fn test_extend_ref ( ) {
248
+ let mut a = EnumSet :: new ( ) ;
249
+ a. insert ( A ) ;
250
+
251
+ a. extend ( & [ A , C ] ) ;
252
+
253
+ assert_eq ! ( a. len( ) , 2 ) ;
254
+ assert ! ( a. contains( & A ) ) ;
255
+ assert ! ( a. contains( & C ) ) ;
256
+
257
+ let mut b = EnumSet :: new ( ) ;
258
+ b. insert ( B ) ;
259
+
260
+ a. extend ( & b) ;
261
+
262
+ assert_eq ! ( a. len( ) , 3 ) ;
263
+ assert ! ( a. contains( & A ) ) ;
264
+ assert ! ( a. contains( & B ) ) ;
265
+ assert ! ( a. contains( & C ) ) ;
266
+ }
You can’t perform that action at this time.
0 commit comments