1 % Using Rust Without the Standard Library
3 Rust’s standard library provides a lot of useful functionality, but assumes
4 support for various features of its host system: threads, networking, heap
5 allocation, and others. There are systems that do not have these features,
6 however, and Rust can work with those too! To do so, we tell Rust that we
7 don’t want to use the standard library via an attribute: `#![no_std]`.
9 > Note: This feature is technically stable, but there are some caveats. For
10 > one, you can build a `#![no_std]` _library_ on stable, but not a _binary_.
11 > For details on binaries without the standard library, see [the nightly
12 > chapter on `#![no_std]`](no-stdlib.html)
14 To use `#![no_std]`, add it to your crate root:
19 fn plus_one(x: i32) -> i32 {
24 Much of the functionality that’s exposed in the standard library is also
25 available via the [`core` crate](../core/index.html). When we’re using the
26 standard library, Rust automatically brings `std` into scope, allowing you to
27 use its features without an explicit import. By the same token, when using
28 `#![no_std]`, Rust will bring `core` into scope for you, as well as [its
29 prelude](../core/prelude/v1/index.html). This means that a lot of code will Just
35 fn may_fail(failure: bool) -> Result<(), &'static str> {
37 Err("this didn’t work!")