impl Default for &mut str

This commit is contained in:
kennytm
2018-06-03 00:29:50 +08:00
parent d830f46b77
commit 0ff8d40fa1
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -1326,6 +1326,7 @@ fn t<S: Default + AsRef<str>>() {
t::<&str>();
t::<String>();
t::<&mut str>();
}
#[test]
+6
View File
@@ -3875,6 +3875,12 @@ impl<'a> Default for &'a str {
fn default() -> &'a str { "" }
}
#[stable(feature = "default_mut_str", since = "1.28.0")]
impl<'a> Default for &'a mut str {
/// Creates an empty mutable str
fn default() -> &'a mut str { unsafe { from_utf8_unchecked_mut(&mut []) } }
}
/// An iterator over the non-whitespace substrings of a string,
/// separated by any amount of whitespace.
///