Skip to content

Commit e3009d3

Browse files
committed
Implement RFC 839 for String
1 parent 11de947 commit e3009d3

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/libcollections/string.rs

+7
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,13 @@ impl Extend<char> for String {
793793
}
794794
}
795795

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+
796803
#[stable(feature = "rust1", since = "1.0.0")]
797804
impl<'a> Extend<&'a str> for String {
798805
fn extend<I: IntoIterator<Item=&'a str>>(&mut self, iterable: I) {

src/libcollectionstest/string.rs

+8
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,14 @@ fn test_drain() {
365365
assert_eq!(t, "");
366366
}
367367

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+
368376
#[bench]
369377
fn bench_with_capacity(b: &mut Bencher) {
370378
b.iter(|| {

0 commit comments

Comments
 (0)