Use LazyLock for std environments and OnceBox for no_std
Description
Right now, we always use once_cell in naga, even when std with LazyLock is available.
Testing
I ran cargo xtask test locally.
Squash or Rebase?
Rebase
Checklist
- [x] Run
cargo fmt. - [x] Run
taplo format. - [x] Run
cargo clippy --tests. If applicable, add:- [x]
--target wasm32-unknown-unknown
- [x]
- [x] Run
cargo xtask testto run tests. - [x] If this contains user-facing changes, add a
CHANGELOG.mdentry.
The "cleanest" way of ensuring that once_lock is actually optional for std builds would be to introduce an explicit std feature. This would, however, mean breaking changes for no_std users, as they would then need to add naga with no default features and the once_cell feature. Would this be okay with you?
@FalkWoldmann: Yes, please! Filed https://github.com/gfx-rs/wgpu/issues/8701 for tracking. 🙂
Just waiting for an answer to this comment before merging; friendly ping for @FalkWoldmann, in case this fell off the radar.
Hi, yeah, sorry! Missed it :) the main motivation is to use the components which are already available via std to reduce the amount of external code that is run. However, we still bundle the dependency, so one could argue if this really changes a lot. I would say so, since I am of the opinion that the std features should always be preferred if they provide the features we need, which is the case here.