From 61dad830b0279aeeeb7b51a7a77d8256373a2462 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Sat, 6 Jan 2024 17:03:44 +0900 Subject: [PATCH 1/3] Update doctests --- CHANGELOG.adoc | 8 +++++++- src/exit_code.rs | 15 +++++++-------- src/lib.rs | 34 ---------------------------------- 3 files changed, 14 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index a8bf274..99d56b2 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -14,7 +14,13 @@ All notable changes to this project will be documented in this file. The format is based on https://keepachangelog.com/[Keep a Changelog], and this project adheres to https://semver.org/[Semantic Versioning]. -== {compare-url}/v0.7.8\...v0.7.9[0.7.9] - 2024-01-06 +== {compare-url}/v0.7.9\...HEAD[Unreleased] + +=== Changed + +* Update doctests ({pull-request-url}/72[#72]) + +== {compare-url}/v0.7.8\...v0.7.9[0.7.9] - 2024-01-06 [YANKED] === Changed diff --git a/src/exit_code.rs b/src/exit_code.rs index ceb85bb..b3eeb3f 100644 --- a/src/exit_code.rs +++ b/src/exit_code.rs @@ -9,8 +9,6 @@ //! [``]: https://man.openbsd.org/sysexits use core::fmt; -#[cfg(feature = "std")] -use std::process::Termination; /// A [`Result`](std::result::Result) type based on [`ExitCode`]. /// @@ -260,8 +258,7 @@ impl ExitCode { /// Terminates the current process with the exit code defined by `ExitCode`. /// - /// This method is equivalent to [`std::process::exit`] with a restricted - /// exit code. + /// Equivalent to [`std::process::exit`] with a restricted exit code. /// /// # Examples /// @@ -344,10 +341,10 @@ impl_from_exit_code_for_integer!(usize); #[cfg(feature = "std")] impl From for std::process::ExitCode { /// Converts an `sysexits::ExitCode` into an [`std::process::ExitCode`]. - /// - /// This method is equivalent to [`ExitCode::report`]. #[inline] fn from(code: ExitCode) -> Self { + use std::process::Termination; + code.report() } } @@ -453,7 +450,7 @@ impl TryFrom for ExitCode { /// /// # Errors /// - /// This method returns [`Err`] in the following situations: + /// Returns [`Err`] if any of the following are true: /// /// - The exit code is not `0` or `64..=78`. /// - The exit code is unknown (e.g., the process was terminated by a @@ -486,7 +483,7 @@ impl TryFrom for ExitCode { impl std::error::Error for ExitCode {} #[cfg(feature = "std")] -impl Termination for ExitCode { +impl std::process::Termination for ExitCode { #[inline] fn report(self) -> std::process::ExitCode { std::process::ExitCode::from(u8::from(self)) @@ -1610,6 +1607,8 @@ mod tests { #[cfg(feature = "std")] #[test] fn report_exit_code() { + use std::process::Termination; + assert_eq!( format!("{:?}", ExitCode::Ok.report()), format!("{:?}", std::process::ExitCode::from(0)) diff --git a/src/lib.rs b/src/lib.rs index a500afe..f46ab73 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,11 +13,6 @@ //! //! # Examples //! -//! ## Returns the exit code as defined by -//! -//! If you only use the exit code as defined by ``, you can return -//! this from the `main` function. -//! //! ``` //! # #[cfg(feature = "std")] //! use std::str; @@ -44,35 +39,6 @@ //! # fn main() {} //! ``` //! -//! ## Combine with other exit codes -//! -//! [`ExitCode`] can be converted to [`std::process::ExitCode`] by the [`From`] -//! trait, so you can combine it with your own exit codes or -//! [`std::process::ExitCode`]. -//! -//! ``` -//! # #[cfg(feature = "std")] -//! use std::{ -//! io::{self, Read}, -//! process::ExitCode, -//! }; -//! -//! # #[cfg(feature = "std")] -//! fn main() -> ExitCode { -//! let mut buf = String::new(); -//! if let Err(err) = io::stdin().read_to_string(&mut buf) { -//! eprintln!("{err}"); -//! sysexits::ExitCode::from(err).into() -//! } else { -//! print!("{buf}"); -//! ExitCode::SUCCESS -//! } -//! } -//! # -//! # #[cfg(not(feature = "std"))] -//! # fn main() {} -//! ``` -//! //! [``]: https://man.openbsd.org/sysexits #![cfg_attr(feature = "extended_io_error", feature(io_error_more))] From 148dd7a6e57295f11327395e8069a8532e442087 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Sat, 6 Jan 2024 17:30:38 +0900 Subject: [PATCH 2/3] Update `ExitCode::report` --- src/exit_code.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exit_code.rs b/src/exit_code.rs index b3eeb3f..9011f1b 100644 --- a/src/exit_code.rs +++ b/src/exit_code.rs @@ -486,7 +486,7 @@ impl std::error::Error for ExitCode {} impl std::process::Termination for ExitCode { #[inline] fn report(self) -> std::process::ExitCode { - std::process::ExitCode::from(u8::from(self)) + u8::from(self).into() } } From 31881fd9bb4e317d7f38dc58c603857dd23433bd Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Sat, 6 Jan 2024 17:41:17 +0900 Subject: [PATCH 3/3] Update version to 0.7.10 --- .bumpversion.toml | 2 +- CHANGELOG.adoc | 2 +- CITATION.cff | 2 +- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- src/lib.rs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index 66c43d2..36aee6c 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -4,7 +4,7 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT [tool.bumpversion] -current_version = "0.7.9" +current_version = "0.7.10" [[tool.bumpversion.files]] filename = "CITATION.cff" diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 99d56b2..76f4fe0 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -14,7 +14,7 @@ All notable changes to this project will be documented in this file. The format is based on https://keepachangelog.com/[Keep a Changelog], and this project adheres to https://semver.org/[Semantic Versioning]. -== {compare-url}/v0.7.9\...HEAD[Unreleased] +== {compare-url}/v0.7.9\...v0.7.10[0.7.10] - 2024-01-06 === Changed diff --git a/CITATION.cff b/CITATION.cff index b6bbff8..1879f93 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -9,7 +9,7 @@ message: Please cite this software using these meta data. # Version information. date-released: 2024-01-06 -version: 0.7.9 +version: 0.7.10 # Project information. abstract: The system exit codes as defined by for Rust diff --git a/Cargo.lock b/Cargo.lock index 127c586..9a50064 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,4 +4,4 @@ version = 3 [[package]] name = "sysexits" -version = "0.7.9" +version = "0.7.10" diff --git a/Cargo.toml b/Cargo.toml index 9c73ca6..6bbec94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ [package] name = "sysexits" -version = "0.7.9" +version = "0.7.10" authors = ["Shun Sakai "] edition = "2021" rust-version = "1.61.0" diff --git a/README.md b/README.md index 2c7013e..ae6504b 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -sysexits = "0.7.9" +sysexits = "0.7.10" ``` ### Example diff --git a/src/lib.rs b/src/lib.rs index f46ab73..f843555 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,7 +42,7 @@ //! [``]: https://man.openbsd.org/sysexits #![cfg_attr(feature = "extended_io_error", feature(io_error_more))] -#![doc(html_root_url = "https://docs.rs/sysexits/0.7.9/")] +#![doc(html_root_url = "https://docs.rs/sysexits/0.7.10/")] #![no_std] #![cfg_attr(doc_cfg, feature(doc_auto_cfg, doc_cfg))] // Lint levels of rustc.