diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2015-06-15 18:33:21 +0200 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2015-07-13 16:21:43 +0200 |
| commit | f9005512a9d84f469b30f0d469ccc401607ce64c (patch) | |
| tree | e1585201e80a2ae90b2ac586f162263a100fbcdc /src/libstd | |
| parent | 90d61d828f82a830b9edc202dd28bb5b4defc7e9 (diff) | |
| download | rust-f9005512a9d84f469b30f0d469ccc401607ce64c.tar.gz rust-f9005512a9d84f469b30f0d469ccc401607ce64c.zip | |
Implement IndexMut for String and str.
... matching the existing Index impls. There is no reason not to if String implement DerefMut. The code removed in `src/librustc/middle/effect.rs` was added in #9750 to prevent things like `s[0] = 0x80` where `s: String`, but I belive became unnecessary when the Index(Mut) traits were introduced.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ascii.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 4a664acc326..cf78fa7b69a 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -583,6 +583,10 @@ mod tests { test!('!', '!'); test!(b"h\xc3\xa9".to_vec(), b"H\xc3\xa9"); test!("hıKß".to_string(), "HıKß"); + + let mut x = "Hello".to_string(); + x[..3].make_ascii_uppercase(); // Test IndexMut on String. + assert_eq!(x, "HELlo") } #[test] |
