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_stdsupport for several crates across the Rust ecosystem, and was surprised to seeronis one such crate! Having such support would be helpful for the Bevy game engine, as we useronfor metadata files. Porting our asset systems tono_stdwill requireronto beno_stdas a prerequisite.Solution
stdfeature.stdenables the usage of thestdcrate.SERDE_FLATTEN_CANARYtest insrc/de/mod.rsto use aStringrather 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_corelints to help with maintainingno_stdsupport.std::iobehindstd.BTreeMapas the inner map for theFieldstype whenstdis not active. This may not need to be feature gated and could be used in both circumstances, but I have not tested to confirm aBTreeMapis equivalently performant.IndexMapto explicitly use thestdRandomStateto highlight how theindexmapfeature could be madeno_stdin the future (requires including an alternative hasher).coreandallocwhere required.stdfeatures from dependencies.f32::fractandf64::fractmethods are not available inno_std. However, they can be accessed usingx % 1.instead.std::error::Errorfromserde::ser::StdError.serdeuses abuild.rsscript to work out whether it can usestd,core, or if it must define its ownErrortrait, and publicly exports it. We can use that instead of needing to determinecorevsstdourselves.Notes
CHANGELOG.md