Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Make Error trait available in no_std mode #115

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .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.74.0 # MSRV
- 1.81.0 # MSRV
- 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 @@ -14,6 +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.8.1\...HEAD[Unreleased]

=== Changed

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

== {compare-url}/v0.8.0\...v0.8.1[0.8.1] - 2024-07-03

=== Changed
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.1"
authors = ["Shun Sakai <[email protected]>"]
edition = "2021"
rust-version = "1.74.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 @@ -75,7 +75,7 @@ See the [documentation][docs-url] for more details.

## Minimum supported Rust version

The minimum supported Rust version (MSRV) of this library is v1.74.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.74.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 @@ -19,8 +19,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 @@ -59,7 +58,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 @@ -95,11 +94,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 @@ -188,8 +184,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: 2 additions & 6 deletions src/exit_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
mod convert;
pub mod result;

use core::fmt;
use core::{error::Error, fmt};

/// `ExitCode` is a type that represents the system exit code constants as
/// defined by [`<sysexits.h>`].
Expand Down Expand Up @@ -287,8 +287,7 @@ impl fmt::Display for 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 @@ -663,11 +662,8 @@ mod tests {
assert!(ExitCode::Config.is_failure());
}

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

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