Closed mina86 closed 1 year ago
Looks good at first glance. Scheduling this for serde-json-wasm 1.0 which will be used in cosmwasm-std 2.0.
Scheduling this for serde-json-wasm 1.0
Is there any reason not to merge this now? Even if it’s not released yet, it’s going to simplify things for people who already need no_std support and maintain their own forks of various cosmwasm packages.
cosmwasm-std 2.0
When exactly does 2.0 happen? It was supposed to be by the end of July but based on the milestone it’s 4% complete so I’m not holding my breath.
Is there any reason not to merge this now? Even if it’s not released yet, it’s going to simplify things for people who already need no_std support and maintain their own forks of various cosmwasm packages.
Adding features breaks default-features = false
callers who enjoyed std before. We might get away with that here but not cosmwasm-std for sure.
no_std support is not on our agenda and nobody is paying us to change that. It's irrelevant for our use case as the wasm32-unknown-unknown target is an std target.
When exactly does 2.0 happen?
When the time is right. If any time was communicated that was a mistake. Sorry for that.
Adding features breaks default-features = false callers who enjoyed std before. We might get away with that here but not cosmwasm-std for sure.
It might not work in cosmwasm-std but that’s conversation for another time. This PR is about serde-json-wasm and here as far as I can tell the solution will work fine.
no_std support is not on our agenda and nobody is paying us to change that.
Which is why I wrote the change and sent the PR. That’s how open source works, isn’t it? People may have their own agendas and features they want so they write patches and contribute them upstream for benefit of everyone.
@webmaster128, how about now then? Since tests are the only part that requires std making this library no_std can be done without introducing a new feature and enabling std when building tests.
Make library no_std and introduce std and unstable features
Remove all references to std from the library and introduce std and unstable features which enable corresponding serde features.
In default build, std is enabled and nothing changes. However, if std is disabled, the library becomes no_std. Downside of lack of std is that Error enum no longer implements std::error;:Error. To remedy that, unstable feature uses core::error::Error but requires a nightly compiler.
For the most part, this commit is mostly just replacing references to std crate with core and alloc crates. On exception is std::error::Error which is replaced by serde’s StdError such that Error enums implement whatever trait serde uses. With std or unstable feature enabled it’s just an alias to {std,core}::error::Error.
Issue: https://github.com/CosmWasm/cosmwasm/issues/1484 Issue: https://github.com/CosmWasm/serde-json-wasm/issues/40