File tree Expand file tree Collapse file tree 4 files changed +19
-10
lines changed Expand file tree Collapse file tree 4 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -2072,7 +2072,8 @@ impl Add<&&String> for String {
2072
2072
/// // `a` is moved and can no longer be used here.
2073
2073
/// ```
2074
2074
///
2075
- /// If you want to keep using the initial `String`, you can clone it and append to the clone instead:
2075
+ /// If you want to keep using the initial `String`, you can clone it and append to the
2076
+ /// clone instead:
2076
2077
///
2077
2078
/// ```
2078
2079
/// let a = String::from("hello world! ");
Original file line number Diff line number Diff line change @@ -195,8 +195,15 @@ fn test_add_assign() {
195
195
assert_eq ! ( s. as_str( ) , "" ) ;
196
196
s += "abc" ;
197
197
assert_eq ! ( s. as_str( ) , "abc" ) ;
198
- s += "ประเทศไทย中华Việt Nam" ;
199
- assert_eq ! ( s. as_str( ) , "abcประเทศไทย中华Việt Nam" ) ;
198
+ s += "ประเทศไทย中华Việt Nam " ;
199
+ assert_eq ! ( s. as_str( ) , "abcประเทศไทย中华Việt Nam " ) ;
200
+
201
+ let s2 = "OPS " . to_string ( ) ;
202
+ s += & s2;
203
+ assert_eq ! ( s. as_str( ) , "abcประเทศไทย中华Việt Nam OPS " ) ;
204
+
205
+ s += '👋' ;
206
+ assert_eq ! ( s. as_str( ) , "abcประเทศไทย中华Việt Nam 👋" ) ;
200
207
}
201
208
202
209
#[ test]
@@ -304,9 +311,10 @@ fn test_str_clear() {
304
311
fn test_str_add ( ) {
305
312
let a = String :: from ( "12345" ) ;
306
313
let b = a + "2" ;
307
- let b = b + "2" ;
308
- assert_eq ! ( b. len( ) , 7 ) ;
309
- assert_eq ! ( b, "1234522" ) ;
314
+ let b = b + "2 " ;
315
+ let b = b + '👋' ;
316
+ assert_eq ! ( b. len( ) , 12 ) ;
317
+ assert_eq ! ( b, "1234522 👋" ) ;
310
318
}
311
319
312
320
#[ test]
Original file line number Diff line number Diff line change @@ -1084,7 +1084,8 @@ impl<'a> Parser<'a> {
1084
1084
if let token:: Literal ( token:: Lit { kind : token:: Integer , symbol, suffix } )
1085
1085
= next_token. kind {
1086
1086
if self . token . span . hi ( ) == next_token. span . lo ( ) {
1087
- // FIXME: Should just be `&symbol.as_str()` but can't as of now due to Deref coercion
1087
+ // FIXME: Should just be `&symbol.as_str()` but can't as of now due to
1088
+ // Deref coercion.
1088
1089
// Issue: https://github.com/rust-lang/rust/issues/51916
1089
1090
let s = String :: from ( "0." ) + & symbol. as_str ( ) . get_str ( ) ;
1090
1091
let kind = TokenKind :: lit ( token:: Float , Symbol :: intern ( & s) , suffix) ;
Original file line number Diff line number Diff line change @@ -1129,9 +1129,8 @@ impl !Sync for SymbolStr {}
1129
1129
/// - `&*ss` is a `&str`;
1130
1130
/// - `&ss as &str` is a `&str`, which means that `&ss` can be passed to a
1131
1131
/// function expecting a `&str`.
1132
- ///
1133
- /// FIXME: This has no meaning anymore since the addition of implementations
1134
- /// of `Add<char> for String`, `Add<&&str> for String`, and `Add<&&String> for String`.
1132
+ ///
1133
+ /// FIXME: This has no meaning anymore since the addition of `impl Add<char> for String`.
1135
1134
/// Due to the outstanding Deref coercion issue this Deref implementation gets ignored.
1136
1135
/// Issue: https://github.com/rust-lang/rust/issues/51916
1137
1136
impl std:: ops:: Deref for SymbolStr {
You can’t perform that action at this time.
0 commit comments