Beyond Standard Rust
The Rust toolchain includes support for a much wider variety of environments than just pure Rust application code, running in userspace:
- It supports cross-compilation, where the system running the toolchain (the host) is not the same as the system that the compiled code will run on (the target), which makes it easy to target embedded systems.
- It supports linking with code compiled from languages other than Rust, via built-in FFI capabilities.
- It supports configurations without the full standard library
std
, allowing systems that do not have a full operating system (e.g., no filesystem, no networking) to be targeted. - It even supports configurations that do not support heap allocation but only have a stack (by omitting use of
the standard
alloc
library).
These nonstandard Rust environments can be harder to work in and may be less safe—they can even be
unsafe
—but they give more options for getting the job done.
This chapter of the book discusses just a few of the basics for working in these environments. Beyond these basics, you'll need to consult more environment-specific documentation (such as the Rustonomicon).