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