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 foreign function interface (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 targetted.
  • It even supports configurations that do not support heap allocation, but which only have a stack.

These non-standard Rust environments are less safe – they are often even unsafe – but give more options for getting the job done.

This part 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).