Skip to content

Commit

Permalink
feat: Make Error trait available in no_std mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Nov 8, 2024
1 parent 1bc67e8 commit 2fce223
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
toolchain:
- 1.62.0 # MSRV
- 1.81.0 # MSRV
- stable
- nightly
include:
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
toolchain:
- 1.74.0
- 1.81.0
- stable
- nightly
include:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ project adheres to https://semver.org/[Semantic Versioning].

=== Changed

* Make `Error` trait available in `no_std` mode ({pull-request-url}/116[#116])
* Bump MSRV to 1.81.0 ({pull-request-url}/116[#116])

== {compare-url}/v0.8.4\...HEAD[Unreleased]

=== Changed

* Change MSRV to 1.62.0 ({pull-request-url}/131[#131])

== {compare-url}/v0.8.3\...v0.8.4[0.8.4] - 2024-10-31
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name = "sysexits"
version = "0.8.4"
authors = ["Shun Sakai <sorairolake@protonmail.ch>"]
edition = "2021"
rust-version = "1.62.0"
rust-version = "1.81.0"
description = "The system exit codes as defined by <sysexits.h>"
documentation = "https://docs.rs/sysexits"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ See the [documentation][docs-url] for more details.

## Minimum supported Rust version

The minimum supported Rust version (MSRV) of this library is v1.62.0.
The minimum supported Rust version (MSRV) of this library is v1.81.0.

## Source code

Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

msrv = "1.62.0"
msrv = "1.81.0"
12 changes: 3 additions & 9 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

//! Error types for this crate.
use core::fmt;
use core::{error::Error, fmt};

/// The error type indicating that [`ExitCode`](crate::ExitCode) was out of
/// range.
Expand All @@ -20,8 +20,7 @@ impl fmt::Display for ExitCodeRangeError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for ExitCodeRangeError {}
impl Error for ExitCodeRangeError {}

#[cfg(feature = "std")]
/// An error which can be returned when converting an
Expand Down Expand Up @@ -61,7 +60,7 @@ impl fmt::Display for TryFromExitStatusError {
}

#[cfg(feature = "std")]
impl std::error::Error for TryFromExitStatusError {}
impl Error for TryFromExitStatusError {}

#[cfg(test)]
mod tests {
Expand Down Expand Up @@ -97,11 +96,8 @@ mod tests {
);
}

#[cfg(feature = "std")]
#[test]
fn source_exit_code_range_error() {
use std::error::Error;

assert!(ExitCodeRangeError.source().is_none());
}

Expand Down Expand Up @@ -190,8 +186,6 @@ mod tests {
#[cfg(feature = "std")]
#[test]
fn source_try_from_exit_status_error() {
use std::error::Error;

assert!(TryFromExitStatusError::new(Some(1)).source().is_none());
assert!(TryFromExitStatusError::new(None).source().is_none());
}
Expand Down
8 changes: 3 additions & 5 deletions src/exit_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ mod convert;
mod fmt;
pub mod result;

use core::error::Error;

/// `ExitCode` is a type that represents the system exit code constants as
/// defined by [`<sysexits.h>`].
///
Expand Down Expand Up @@ -272,8 +274,7 @@ impl ExitCode {
}
}

#[cfg(feature = "std")]
impl std::error::Error for ExitCode {}
impl Error for ExitCode {}

#[cfg(feature = "std")]
impl std::process::Termination for ExitCode {
Expand Down Expand Up @@ -633,11 +634,8 @@ mod tests {
assert!(ExitCode::Config.is_failure());
}

#[cfg(feature = "std")]
#[test]
fn source() {
use std::error::Error;

assert!(ExitCode::Ok.source().is_none());
assert!(ExitCode::Usage.source().is_none());
assert!(ExitCode::DataErr.source().is_none());
Expand Down

0 comments on commit 2fce223

Please sign in to comment.