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

Support no_std in hexf-parse. #28

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sunfishcode
Copy link
Contributor

Support no_std in hexf-parse, by adding a "std" feature, enabled by default, and putting the impl of std::error::Error behind it.

Support `no_std` in hexf-parse, by adding a "std" feature, enabled by
default, and putting the impl of `std::error::Error` behind it.
@skewballfox
Copy link

ps looks like Error in core has been merged

@sunfishcode
Copy link
Contributor Author

I've now updated the PR to use core::error::Error in no_std mode.

Comment on lines +63 to +75
#[cfg(feature = "std")]
impl std::error::Error for ParseHexfError {
fn description(&self) -> &'static str {
self.text()
}
}

#[cfg(not(feature = "std"))]
impl core::error::Error for ParseHexfError {
fn description(&self) -> &'static str {
self.text()
}
}
Copy link
Collaborator

@youknowone youknowone Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be simply replaced to core::error::Error? Otherwise are those different types?

Suggested change
#[cfg(feature = "std")]
impl std::error::Error for ParseHexfError {
fn description(&self) -> &'static str {
self.text()
}
}
#[cfg(not(feature = "std"))]
impl core::error::Error for ParseHexfError {
fn description(&self) -> &'static str {
self.text()
}
}
impl core::error::Error for ParseHexfError {
fn description(&self) -> &'static str {
self.text()
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README.md advertises support for Rust 1.43; core::error::Error was introduced in Rust 1.81.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants