You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great to have no_std support for thiserror, and after a look over the codebase I don't think it would be very difficult, I'm just inexperienced with proc-macros. The only drawbacks (and thus make no_std compatibility require a feature flag) would be that std::error::Error and std::path are not core or alloc friendly. For the most part, migration would be easy as changing std imports to core or alloc, but for the aforementioned roadblocks I propose the following:
Add #![cfg_attr(feature = "no_std", no_std)] to the root of the thiserror crate to enable no_std for the no_std feature
Add a feature to both thiserror and thiserror-impl, possibly something like no_std, this would look about like this
# In thiserror
[features]
default = []
no_std = ["thiserror-impl/no_std"]
# In thiserror-impl
[features]
default = []
no_std = []
And then for problematic areas, like thiserror/src/aserror.rs and thiserror/src/display.rs, simply conditionally compile them when the no_std feature is not active using #[cfg(not(feature = "no_std))]
Lastly there'd be the normal changing std to core/alloc, but adding conditional compilation to places where aserror.rs and display.rs are used would also be needed
The text was updated successfully, but these errors were encountered:
It would be great to have no_std support for thiserror, and after a look over the codebase I don't think it would be very difficult, I'm just inexperienced with proc-macros. The only drawbacks (and thus make no_std compatibility require a feature flag) would be that
std::error::Error
andstd::path
are notcore
oralloc
friendly. For the most part, migration would be easy as changingstd
imports tocore
oralloc
, but for the aforementioned roadblocks I propose the following:Add
#![cfg_attr(feature = "no_std", no_std)]
to the root of thethiserror
crate to enable no_std for theno_std
featureAdd a feature to both
thiserror
andthiserror-impl
, possibly something likeno_std
, this would look about like thisAnd then for problematic areas, like
thiserror/src/aserror.rs
andthiserror/src/display.rs
, simply conditionally compile them when the no_std feature is not active using#[cfg(not(feature = "no_std))]
Lastly there'd be the normal changing
std
tocore
/alloc
, but adding conditional compilation to places whereaserror.rs
anddisplay.rs
are used would also be neededThe text was updated successfully, but these errors were encountered: