diff options
| author | Markus Reiter <me@reitermark.us> | 2024-02-19 06:02:17 +0100 |
|---|---|---|
| committer | Markus Reiter <me@reitermark.us> | 2024-02-22 15:17:33 +0100 |
| commit | e0732e42d829cd8aa8480811d0c860387437e6ca (patch) | |
| tree | bc2ec64e6b5f516aed3b86feabf03c00a1401bfc /library/std/src/process.rs | |
| parent | 14ed426eec6939737ea320e50bb28d239c7aee93 (diff) | |
| download | rust-e0732e42d829cd8aa8480811d0c860387437e6ca.tar.gz rust-e0732e42d829cd8aa8480811d0c860387437e6ca.zip | |
Use generic `NonZero` everywhere in `std`.
Diffstat (limited to 'library/std/src/process.rs')
| -rw-r--r-- | library/std/src/process.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 669affa266a..b84d5f11954 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -111,7 +111,7 @@ use crate::ffi::OsStr; use crate::fmt; use crate::fs; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; -use crate::num::NonZeroI32; +use crate::num::NonZero; use crate::path::Path; use crate::str; use crate::sys::pipe::{read2, AnonPipe}; @@ -1775,9 +1775,9 @@ impl ExitStatusError { self.code_nonzero().map(Into::into) } - /// Reports the exit code, if applicable, from an `ExitStatusError`, as a `NonZero` + /// Reports the exit code, if applicable, from an `ExitStatusError`, as a [`NonZero`]. /// - /// This is exactly like [`code()`](Self::code), except that it returns a `NonZeroI32`. + /// This is exactly like [`code()`](Self::code), except that it returns a <code>[NonZero]<[i32]></code>. /// /// Plain `code`, returning a plain integer, is provided because it is often more convenient. /// The returned value from `code()` is indeed also nonzero; use `code_nonzero()` when you want @@ -1786,17 +1786,17 @@ impl ExitStatusError { /// # Examples /// /// ``` - /// #![feature(exit_status_error)] + /// #![feature(exit_status_error, generic_nonzero)] /// # if cfg!(unix) { - /// use std::num::NonZeroI32; + /// use std::num::NonZero; /// use std::process::Command; /// /// let bad = Command::new("false").status().unwrap().exit_ok().unwrap_err(); - /// assert_eq!(bad.code_nonzero().unwrap(), NonZeroI32::try_from(1).unwrap()); + /// assert_eq!(bad.code_nonzero().unwrap(), NonZero::new(1).unwrap()); /// # } // cfg!(unix) /// ``` #[must_use] - pub fn code_nonzero(&self) -> Option<NonZeroI32> { + pub fn code_nonzero(&self) -> Option<NonZero<i32>> { self.0.code() } |
