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.
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user