impl Default for &mut str

This commit is contained in:
kennytm 2018-06-03 00:29:50 +08:00
parent d830f46b77
commit 0ff8d40fa1
No known key found for this signature in database
GPG key ID: FEF6C8051D0E013C
2 changed files with 7 additions and 0 deletions

View file

@ -1326,6 +1326,7 @@ fn test_str_default() {
t::<&str>();
t::<String>();
t::<&mut str>();
}
#[test]

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.
///