Skip to content

Commit db0cbc4

Browse files
committed
Auto merge of #109357 - saethlin:inline-as-deref, r=thomcc
Add #[inline] to as_deref While working on #109247 I found an `as_deref` call in the compiler that should have been inlined. This fixes the missing inlining (but doesn't address the perf issues I was chasing). r? `@thomcc`
2 parents 89c2e3d + d3352de commit db0cbc4

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

library/core/src/option.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,7 @@ impl<T> Option<T> {
12741274
/// let x: Option<String> = None;
12751275
/// assert_eq!(x.as_deref(), None);
12761276
/// ```
1277+
#[inline]
12771278
#[stable(feature = "option_deref", since = "1.40.0")]
12781279
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
12791280
pub const fn as_deref(&self) -> Option<&T::Target>
@@ -1300,6 +1301,7 @@ impl<T> Option<T> {
13001301
/// x
13011302
/// }), Some("HEY".to_owned().as_mut_str()));
13021303
/// ```
1304+
#[inline]
13031305
#[stable(feature = "option_deref", since = "1.40.0")]
13041306
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
13051307
pub const fn as_deref_mut(&mut self) -> Option<&mut T::Target>

library/core/src/result.rs

+2
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ impl<T, E> Result<T, E> {
908908
/// let y: Result<&str, &u32> = Err(&42);
909909
/// assert_eq!(x.as_deref(), y);
910910
/// ```
911+
#[inline]
911912
#[stable(feature = "inner_deref", since = "1.47.0")]
912913
pub fn as_deref(&self) -> Result<&T::Target, &E>
913914
where
@@ -934,6 +935,7 @@ impl<T, E> Result<T, E> {
934935
/// let y: Result<&mut str, &mut u32> = Err(&mut i);
935936
/// assert_eq!(x.as_deref_mut().map(|x| { x.make_ascii_uppercase(); x }), y);
936937
/// ```
938+
#[inline]
937939
#[stable(feature = "inner_deref", since = "1.47.0")]
938940
pub fn as_deref_mut(&mut self) -> Result<&mut T::Target, &mut E>
939941
where

0 commit comments

Comments
 (0)