Skip to content

Commit 835310e

Browse files
authored
Rollup merge of #78073 - fusion-engineering-forks:inline, r=eddyb
Add #[inline] to some functions in core::str. Almost all str functions already had #[inline].
2 parents 1d5b7c3 + cc850ec commit 835310e

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

library/core/src/str/error.rs

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ impl Utf8Error {
7272
/// assert_eq!(1, error.valid_up_to());
7373
/// ```
7474
#[stable(feature = "utf8_error", since = "1.5.0")]
75+
#[inline]
7576
pub fn valid_up_to(&self) -> usize {
7677
self.valid_up_to
7778
}
@@ -92,6 +93,7 @@ impl Utf8Error {
9293
///
9394
/// [U+FFFD]: ../../std/char/constant.REPLACEMENT_CHARACTER.html
9495
#[stable(feature = "utf8_error_error_len", since = "1.20.0")]
96+
#[inline]
9597
pub fn error_len(&self) -> Option<usize> {
9698
self.error_len.map(|len| len as usize)
9799
}

library/core/src/str/iter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ unsafe impl TrustedLen for Bytes<'_> {}
326326
#[doc(hidden)]
327327
#[unstable(feature = "trusted_random_access", issue = "none")]
328328
unsafe impl TrustedRandomAccess for Bytes<'_> {
329+
#[inline]
329330
fn may_have_side_effect() -> bool {
330331
false
331332
}

library/core/src/str/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,7 @@ impl str {
17121712
///
17131713
/// assert_eq!("Hello\tworld", s.trim());
17141714
/// ```
1715+
#[inline]
17151716
#[must_use = "this returns the trimmed string as a slice, \
17161717
without modifying the original"]
17171718
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1749,6 +1750,7 @@ impl str {
17491750
/// let s = " עברית ";
17501751
/// assert!(Some('ע') == s.trim_start().chars().next());
17511752
/// ```
1753+
#[inline]
17521754
#[must_use = "this returns the trimmed string as a new slice, \
17531755
without modifying the original"]
17541756
#[stable(feature = "trim_direction", since = "1.30.0")]
@@ -1786,6 +1788,7 @@ impl str {
17861788
/// let s = " עברית ";
17871789
/// assert!(Some('ת') == s.trim_end().chars().rev().next());
17881790
/// ```
1791+
#[inline]
17891792
#[must_use = "this returns the trimmed string as a new slice, \
17901793
without modifying the original"]
17911794
#[stable(feature = "trim_direction", since = "1.30.0")]
@@ -1824,6 +1827,7 @@ impl str {
18241827
/// let s = " עברית";
18251828
/// assert!(Some('ע') == s.trim_left().chars().next());
18261829
/// ```
1830+
#[inline]
18271831
#[stable(feature = "rust1", since = "1.0.0")]
18281832
#[rustc_deprecated(
18291833
since = "1.33.0",
@@ -1865,6 +1869,7 @@ impl str {
18651869
/// let s = "עברית ";
18661870
/// assert!(Some('ת') == s.trim_right().chars().rev().next());
18671871
/// ```
1872+
#[inline]
18681873
#[stable(feature = "rust1", since = "1.0.0")]
18691874
#[rustc_deprecated(
18701875
since = "1.33.0",
@@ -2260,6 +2265,7 @@ impl str {
22602265
/// assert_eq!("GRüßE, JüRGEN ❤", s);
22612266
/// ```
22622267
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
2268+
#[inline]
22632269
pub fn make_ascii_uppercase(&mut self) {
22642270
// SAFETY: safe because we transmute two types with the same layout.
22652271
let me = unsafe { self.as_bytes_mut() };
@@ -2286,6 +2292,7 @@ impl str {
22862292
/// assert_eq!("grÜße, jÜrgen ❤", s);
22872293
/// ```
22882294
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
2295+
#[inline]
22892296
pub fn make_ascii_lowercase(&mut self) {
22902297
// SAFETY: safe because we transmute two types with the same layout.
22912298
let me = unsafe { self.as_bytes_mut() };
@@ -2423,6 +2430,7 @@ impl AsRef<[u8]> for str {
24232430
#[stable(feature = "rust1", since = "1.0.0")]
24242431
impl Default for &str {
24252432
/// Creates an empty str
2433+
#[inline]
24262434
fn default() -> Self {
24272435
""
24282436
}
@@ -2431,6 +2439,7 @@ impl Default for &str {
24312439
#[stable(feature = "default_mut_str", since = "1.28.0")]
24322440
impl Default for &mut str {
24332441
/// Creates an empty mutable str
2442+
#[inline]
24342443
fn default() -> Self {
24352444
// SAFETY: The empty string is valid UTF-8.
24362445
unsafe { from_utf8_unchecked_mut(&mut []) }

0 commit comments

Comments
 (0)