Rollup merge of #83555 - m-ou-se:inline-io-error-new-const, r=jackh726
Add #[inline] to io::Error methods Fixes #82812
This commit is contained in:
commit
7d6af6751c
1 changed files with 8 additions and 0 deletions
|
@ -269,6 +269,7 @@ impl Error {
|
||||||
/// This function should maybe change to
|
/// This function should maybe change to
|
||||||
/// `new_const<const MSG: &'static str>(kind: ErrorKind)`
|
/// `new_const<const MSG: &'static str>(kind: ErrorKind)`
|
||||||
/// in the future, when const generics allow that.
|
/// in the future, when const generics allow that.
|
||||||
|
#[inline]
|
||||||
pub(crate) const fn new_const(kind: ErrorKind, message: &'static &'static str) -> Error {
|
pub(crate) const fn new_const(kind: ErrorKind, message: &'static &'static str) -> Error {
|
||||||
Self { repr: Repr::SimpleMessage(kind, message) }
|
Self { repr: Repr::SimpleMessage(kind, message) }
|
||||||
}
|
}
|
||||||
|
@ -287,6 +288,7 @@ impl Error {
|
||||||
/// println!("last OS error: {:?}", Error::last_os_error());
|
/// println!("last OS error: {:?}", Error::last_os_error());
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[inline]
|
||||||
pub fn last_os_error() -> Error {
|
pub fn last_os_error() -> Error {
|
||||||
Error::from_raw_os_error(sys::os::errno() as i32)
|
Error::from_raw_os_error(sys::os::errno() as i32)
|
||||||
}
|
}
|
||||||
|
@ -317,6 +319,7 @@ impl Error {
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[inline]
|
||||||
pub fn from_raw_os_error(code: i32) -> Error {
|
pub fn from_raw_os_error(code: i32) -> Error {
|
||||||
Error { repr: Repr::Os(code) }
|
Error { repr: Repr::Os(code) }
|
||||||
}
|
}
|
||||||
|
@ -351,6 +354,7 @@ impl Error {
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[inline]
|
||||||
pub fn raw_os_error(&self) -> Option<i32> {
|
pub fn raw_os_error(&self) -> Option<i32> {
|
||||||
match self.repr {
|
match self.repr {
|
||||||
Repr::Os(i) => Some(i),
|
Repr::Os(i) => Some(i),
|
||||||
|
@ -388,6 +392,7 @@ impl Error {
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "io_error_inner", since = "1.3.0")]
|
#[stable(feature = "io_error_inner", since = "1.3.0")]
|
||||||
|
#[inline]
|
||||||
pub fn get_ref(&self) -> Option<&(dyn error::Error + Send + Sync + 'static)> {
|
pub fn get_ref(&self) -> Option<&(dyn error::Error + Send + Sync + 'static)> {
|
||||||
match self.repr {
|
match self.repr {
|
||||||
Repr::Os(..) => None,
|
Repr::Os(..) => None,
|
||||||
|
@ -460,6 +465,7 @@ impl Error {
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "io_error_inner", since = "1.3.0")]
|
#[stable(feature = "io_error_inner", since = "1.3.0")]
|
||||||
|
#[inline]
|
||||||
pub fn get_mut(&mut self) -> Option<&mut (dyn error::Error + Send + Sync + 'static)> {
|
pub fn get_mut(&mut self) -> Option<&mut (dyn error::Error + Send + Sync + 'static)> {
|
||||||
match self.repr {
|
match self.repr {
|
||||||
Repr::Os(..) => None,
|
Repr::Os(..) => None,
|
||||||
|
@ -497,6 +503,7 @@ impl Error {
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "io_error_inner", since = "1.3.0")]
|
#[stable(feature = "io_error_inner", since = "1.3.0")]
|
||||||
|
#[inline]
|
||||||
pub fn into_inner(self) -> Option<Box<dyn error::Error + Send + Sync>> {
|
pub fn into_inner(self) -> Option<Box<dyn error::Error + Send + Sync>> {
|
||||||
match self.repr {
|
match self.repr {
|
||||||
Repr::Os(..) => None,
|
Repr::Os(..) => None,
|
||||||
|
@ -525,6 +532,7 @@ impl Error {
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[inline]
|
||||||
pub fn kind(&self) -> ErrorKind {
|
pub fn kind(&self) -> ErrorKind {
|
||||||
match self.repr {
|
match self.repr {
|
||||||
Repr::Os(code) => sys::decode_error_kind(code),
|
Repr::Os(code) => sys::decode_error_kind(code),
|
||||||
|
|
Loading…
Add table
Reference in a new issue