bevy_platform/lib.rs
1#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2#![doc(
3 html_logo_url = "https://bevy.org/assets/icon.png",
4 html_favicon_url = "https://bevy.org/assets/icon.png"
5)]
6#![no_std]
7
8//! Platform compatibility support for first-party [Bevy] engine crates.
9//!
10//! [Bevy]: https://bevy.org/
11
12cfg::std! {
13 extern crate std;
14}
15
16cfg::alloc! {
17 extern crate alloc;
18
19 pub mod collections;
20}
21
22pub mod cell;
23pub mod cfg;
24pub mod hash;
25pub mod sync;
26pub mod thread;
27pub mod time;
28
29/// Frequently used items which would typically be included in most contexts.
30///
31/// When adding `no_std` support to a crate for the first time, often there's a substantial refactor
32/// required due to the change in implicit prelude from `std::prelude` to `core::prelude`.
33/// This unfortunately leaves out many items from `alloc`, even if the crate unconditionally
34/// includes that crate.
35///
36/// This prelude aims to ease the transition by re-exporting items from `alloc` which would
37/// otherwise be included in the `std` implicit prelude.
38pub mod prelude {
39 crate::cfg::alloc! {
40 pub use alloc::{
41 borrow::ToOwned, boxed::Box, format, string::String, string::ToString, vec, vec::Vec,
42 };
43 }
44
45 // Items from `std::prelude` that are missing in this module:
46 // * dbg
47 // * eprint
48 // * eprintln
49 // * is_x86_feature_detected
50 // * print
51 // * println
52 // * thread_local
53}
54
55/// Re-exports of crates that are useful across Bevy.
56/// Not intended for external crates to use.
57#[doc(hidden)]
58pub mod exports {
59 crate::cfg::web! {
60 pub use js_sys;
61 pub use wasm_bindgen;
62 pub use wasm_bindgen_futures;
63 }
64}