File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -793,6 +793,13 @@ impl Extend<char> for String {
793
793
}
794
794
}
795
795
796
+ #[ unstable( feature = "extend_ref" , reason = "recently added" ) ]
797
+ impl < ' a > Extend < & ' a char > for String {
798
+ fn extend < I : IntoIterator < Item =& ' a char > > ( & mut self , iter : I ) {
799
+ self . extend ( iter. into_iter ( ) . cloned ( ) ) ;
800
+ }
801
+ }
802
+
796
803
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
797
804
impl < ' a > Extend < & ' a str > for String {
798
805
fn extend < I : IntoIterator < Item =& ' a str > > ( & mut self , iterable : I ) {
Original file line number Diff line number Diff line change @@ -365,6 +365,14 @@ fn test_drain() {
365
365
assert_eq ! ( t, "" ) ;
366
366
}
367
367
368
+ #[ test]
369
+ fn test_extend_ref ( ) {
370
+ let mut a = "foo" . to_string ( ) ;
371
+ a. extend ( & [ 'b' , 'a' , 'r' ] ) ;
372
+
373
+ assert_eq ! ( & a, "foobar" ) ;
374
+ }
375
+
368
376
#[ bench]
369
377
fn bench_with_capacity ( b : & mut Bencher ) {
370
378
b. iter ( || {
You can’t perform that action at this time.
0 commit comments