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

Features/no std #171

Merged
merged 2 commits into from
Aug 4, 2021
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: 2 additions & 0 deletions strum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ strum_macros = { path = "../strum_macros", version = "0.21" }
travis-ci = { repository = "Peternator7/strum" }

[features]
default = ["std"]
derive = ["strum_macros"]
std = []

[package.metadata.docs.rs]
features = ["derive"]
Expand Down
5 changes: 5 additions & 0 deletions strum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
//! ```
//!


#![cfg_attr(not(feature = "std"), no_std)]

#![cfg_attr(docsrs, feature(doc_cfg))]

// only for documentation purposes
Expand All @@ -36,6 +39,7 @@ pub enum ParseError {
VariantNotFound,
}

#[cfg(feature = "std")]
impl std::fmt::Display for ParseError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
// We could use our macro here, but this way we don't take a dependency on the
Expand All @@ -46,6 +50,7 @@ impl std::fmt::Display for ParseError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for ParseError {
fn description(&self) -> &str {
match self {
Expand Down