-
Notifications
You must be signed in to change notification settings - Fork 133
Add no_std
Support
#567
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
Add no_std
Support
#567
Conversation
Thank you for working on this feature! I think the next step would be to fix CI by ensuring only the right feature combinations are tested. In particular, the core error feature should be run with the 1.77. |
Damn, thought I'd caught all the CI issues already. I'll do another pass tonight and try and fix those issues too. |
As you might see, clippy on >1.64 flags lots of things that we cannot use on 1.64. So while you're free to fix some of them, we only run clippy on the MSRV for this reason |
Ok looks like it's just an issue with |
Nit: could the CI matrix case names be changed so that instead of e.g. false, true, false, true we'd see the features used? |
I'd love to do that. I think it's controlled by |
Ok I think the |
`serde` re-exports what it requires as an `Error` trait already, so we can use that to avoid feature complexity.
Ok the last CI failure was very informative, and I've been able to remove that |
Thanks @bushrat011899 for all of your work on this! I was wondering, now that the feature matrix is simpler again, if we could use cargo hack instead of a GitHub matrix to make use of caching and not spawn so many jobs. |
Ping @bushrat011899 |
Co-Authored-By: Juniper Tyree <50025784+juntyr@users.noreply.github.com>
Sorry about the delayed response! Got distracted and forgot to come back to this, thanks for the ping! I've updated the CI task to use |
Thanks @bushrat011899! Finally, could you also write the CHANGELOG entry and then I'll merge your PR :) |
Compared against `cargo-semver-checks` to ensure all breaking changes are captured. Note that while I have listed this as a breaking change, it technically isn't, as the functionality is still available with default features enabled.
Done! I've listed it as a breaking change, but it technically isn't since nothing has changed when default features are enabled. I explicitly included all items which are now gated behind |
Thank you so much @bushrat011899 for all the work you put into this PR <3 |
Objective
I'm working on
no_std
support for several crates across the Rust ecosystem, and was surprised to seeron
is one such crate! Having such support would be helpful for the Bevy game engine, as we useron
for metadata files. Porting our asset systems tono_std
will requireron
to beno_std
as a prerequisite.Solution
std
feature.std
enables the usage of thestd
crate.SERDE_FLATTEN_CANARY
test insrc/de/mod.rs
to use aString
rather than a byte array. This may require more investigation. I believe my fix is correct, but may over-allocate.alloc_instead_of_core
,std_instead_of_alloc
, andstd_instead_of_core
lints to help with maintainingno_std
support.std::io
behindstd
.BTreeMap
as the inner map for theFields
type whenstd
is not active. This may not need to be feature gated and could be used in both circumstances, but I have not tested to confirm aBTreeMap
is equivalently performant.IndexMap
to explicitly use thestd
RandomState
to highlight how theindexmap
feature could be madeno_std
in the future (requires including an alternative hasher).core
andalloc
where required.std
features from dependencies.f32::fract
andf64::fract
methods are not available inno_std
. However, they can be accessed usingx % 1.
instead.std::error::Error
fromserde::ser::StdError
.serde
uses abuild.rs
script to work out whether it can usestd
,core
, or if it must define its ownError
trait, and publicly exports it. We can use that instead of needing to determinecore
vsstd
ourselves.Notes
CHANGELOG.md