Skip to content

Commit

Permalink
block-padding+inout: remove std feature (#1117)
Browse files Browse the repository at this point in the history
Leverages the `error_in_core` feature stabilized in Rust 1.81 to allow
`Error` trait impls in `no_std` contexts.

This was the only dependency on `std`, so this also removes the `std`
feature, which is no longer necessary.
  • Loading branch information
tarcieri authored Sep 28, 2024
1 parent 021e014 commit ab0c802
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 36 deletions.
7 changes: 0 additions & 7 deletions block-padding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,3 @@ readme = "README.md"

[dependencies]
hybrid-array = "0.2.0-rc.10"

[features]
std = []

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
8 changes: 1 addition & 7 deletions block-padding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg",
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg"
)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs, rust_2018_idioms)]

#[cfg(feature = "std")]
extern crate std;

pub use hybrid_array as array;

use core::fmt;
Expand Down Expand Up @@ -399,6 +395,4 @@ impl fmt::Display for UnpadError {
}
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for UnpadError {}
impl core::error::Error for UnpadError {}
7 changes: 0 additions & 7 deletions inout/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,3 @@ readme = "README.md"
[dependencies]
block-padding = { version = "0.4.0-rc.0", path = "../block-padding", optional = true }
hybrid-array = "0.2.0-rc.10"

[features]
std = ["block-padding/std"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
16 changes: 4 additions & 12 deletions inout/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ impl fmt::Display for IntoArrayError {
}
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for IntoArrayError {}
impl core::error::Error for IntoArrayError {}

/// The error returned when input and output slices have different length
/// and thus can not be converted to `InOutBuf`.
Expand All @@ -25,9 +23,7 @@ impl fmt::Display for NotEqualError {
}
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for NotEqualError {}
impl core::error::Error for NotEqualError {}

/// Padding error. Usually emitted when size of output buffer is insufficient.
#[cfg(feature = "block-padding")]
Expand All @@ -43,9 +39,7 @@ impl fmt::Display for PadError {
}

#[cfg(feature = "block-padding")]
#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for PadError {}
impl core::error::Error for PadError {}

/// Output buffer is smaller than input buffer.
#[derive(Clone, Copy, Debug)]
Expand All @@ -57,6 +51,4 @@ impl fmt::Display for OutIsTooSmallError {
}
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for OutIsTooSmallError {}
impl core::error::Error for OutIsTooSmallError {}
3 changes: 0 additions & 3 deletions inout/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs, rust_2018_idioms)]

#[cfg(feature = "std")]
extern crate std;

#[cfg(feature = "block-padding")]
#[cfg_attr(docsrs, doc(cfg(feature = "block-padding")))]
pub use block_padding;
Expand Down

0 comments on commit ab0c802

Please sign in to comment.