Skip to content

Commit 233f242

Browse files
authored
Rollup merge of rust-lang#109357 - saethlin:inline-as-deref, r=thomcc
Add #[inline] to as_deref While working on rust-lang#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 374d005 + d3352de commit 233f242

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
@@ -1310,6 +1310,7 @@ impl<T> Option<T> {
13101310
/// let x: Option<String> = None;
13111311
/// assert_eq!(x.as_deref(), None);
13121312
/// ```
1313+
#[inline]
13131314
#[stable(feature = "option_deref", since = "1.40.0")]
13141315
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
13151316
pub const fn as_deref(&self) -> Option<&T::Target>
@@ -1336,6 +1337,7 @@ impl<T> Option<T> {
13361337
/// x
13371338
/// }), Some("HEY".to_owned().as_mut_str()));
13381339
/// ```
1340+
#[inline]
13391341
#[stable(feature = "option_deref", since = "1.40.0")]
13401342
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
13411343
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)