File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
branches/snap-stage3/src/libcollections Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
refs/heads/master: 7a93beef7f692b34168ad69633f56483d38ad8fc
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
- refs/heads/snap-stage3: 05ca9f747d62c9385cc142daa3c24a32d32a3f16
4
+ refs/heads/snap-stage3: f7f95c8f5a6294f161800dbb65a0423bb5248f34
5
5
refs/heads/try: 1813e5aa1a03b0596b8de7abd1af31edf5d6098f
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
Original file line number Diff line number Diff line change @@ -352,6 +352,14 @@ impl<'a, S: Str> Equiv<S> for String {
352
352
}
353
353
}
354
354
355
+ impl < S : Str > Add < S , String > for String {
356
+ fn add ( & self , other : & S ) -> String {
357
+ let mut s = self . to_string ( ) ;
358
+ s. push_str ( other. as_slice ( ) ) ;
359
+ return s;
360
+ }
361
+ }
362
+
355
363
#[ cfg( test) ]
356
364
mod tests {
357
365
use std:: prelude:: * ;
@@ -469,4 +477,13 @@ mod tests {
469
477
assert_eq ! ( s. len( ) , 0 ) ;
470
478
assert_eq ! ( s. as_slice( ) , "" ) ;
471
479
}
480
+
481
+ #[ test]
482
+ fn test_str_add ( ) {
483
+ let a = String :: from_str ( "12345" ) ;
484
+ let b = a + "2" ;
485
+ let b = b + String :: from_str ( "2" ) ;
486
+ assert_eq ! ( b. len( ) , 7 ) ;
487
+ assert_eq ! ( b. as_slice( ) , "1234522" ) ;
488
+ }
472
489
}
You can’t perform that action at this time.
0 commit comments