Skip to content

Commit

Permalink
Add #[inline] to {&str, &mut str}::default.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Oct 18, 2020
1 parent 76daca2 commit cc850ec
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2431,6 +2431,7 @@ impl AsRef<[u8]> for str {
#[stable(feature = "rust1", since = "1.0.0")]
impl Default for &str {
/// Creates an empty str
#[inline]
fn default() -> Self {
""
}
Expand All @@ -2439,6 +2440,7 @@ impl Default for &str {
#[stable(feature = "default_mut_str", since = "1.28.0")]
impl Default for &mut str {
/// Creates an empty mutable str
#[inline]
fn default() -> Self {
// SAFETY: The empty string is valid UTF-8.
unsafe { from_utf8_unchecked_mut(&mut []) }
Expand Down

0 comments on commit cc850ec

Please sign in to comment.