bevy/examples/no_std
Zachary Harrold 958c9bb652
Add no_std Library Example (#18333)
# Objective

- Fixes #17506
- Fixes #16258

## Solution

- Added a new folder of examples, `no_std`, similar to the `mobile`
folder.
- Added a single example, `no_std_library`, which demonstrates how to
make a `no_std` compatible Bevy library.
- Added a new CI task, `check-compiles-no-std-examples`, which checks
that `no_std` examples compile on `no_std` targets.
- Added `bevy_platform_support::prelude` to `bevy::prelude`.

## Testing

- CI

---

## Notes

- I've structured the folders here to permit further `no_std` examples
(e.g., GameBoy Games, ESP32 firmware, etc.), but I am starting with the
simplest and least controversial example.
- I've tried to be as clear as possible with the documentation for this
example, catering to an audience who may not have even heard of `no_std`
before.

---------

Co-authored-by: Greeble <166992735+greeble-dev@users.noreply.github.com>
2025-03-18 00:45:25 +00:00
..
library Add no_std Library Example (#18333) 2025-03-18 00:45:25 +00:00
README.md Add no_std Library Example (#18333) 2025-03-18 00:45:25 +00:00

no_std Examples

This folder contains examples for how to work with no_std targets and Bevy. Refer to each example individually for details around how it works and what features you may need to enable/disable to allow a particular target to work.

What is no_std?

no_std is a Rust term for software which doesn't rely on the standard library, std. The typical use for no_std is in embedded software, where the device simply doesn't support the standard library. For example, a Raspberry Pi Pico has no operating system to support threads or filesystem operations.

For these platforms, Rust has a more fundamental alternative to std, core. A large portion of Rust's std actually just re-exports items from core, such as iterators, Result, and Option.

In addition, std also re-exports from another crate, alloc. This crate is similar to core in that it's generally available on all platforms. Where it differs is that its inclusion requires access to a global allocator. Currently, Bevy relies heavily on allocation, so we consider alloc to be just as available, since without it, Bevy will not compile.