File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed 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
- refs/heads/master: 05ca9f747d62c9385cc142daa3c24a32d32a3f16
2
+ refs/heads/master: f7f95c8f5a6294f161800dbb65a0423bb5248f34
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 71fe44def9676d519f5ce5d7304e581a42cf2c70
5
5
refs/heads/try: 1813e5aa1a03b0596b8de7abd1af31edf5d6098f
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