Skip to content

Commit 96cafc5

Browse files
committed
Auto merge of #54613 - matthiaskrgr:string_from_inline_53681, r=nagisa
liballoc: mark str.to_owned() and String::from(&str) as #[inline]. Fixes #53681
2 parents 0e07c42 + d24070b commit 96cafc5

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

Diff for: src/liballoc/str.rs

+1
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ impl Borrow<str> for String {
203203
#[stable(feature = "rust1", since = "1.0.0")]
204204
impl ToOwned for str {
205205
type Owned = String;
206+
#[inline]
206207
fn to_owned(&self) -> String {
207208
unsafe { String::from_utf8_unchecked(self.as_bytes().to_owned()) }
208209
}

Diff for: src/liballoc/string.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,7 @@ impl AsRef<[u8]> for String {
21962196

21972197
#[stable(feature = "rust1", since = "1.0.0")]
21982198
impl<'a> From<&'a str> for String {
2199+
#[inline]
21992200
fn from(s: &'a str) -> String {
22002201
s.to_owned()
22012202
}

0 commit comments

Comments
 (0)