Skip to content

Commit acf3b6c

Browse files
committed
doc: add rust-std chapter to book
1 parent c5d5d80 commit acf3b6c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

book/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [Using Protocols](how_to/protocols.md)
1111
- [Drawing to the Screen](how_to/drawing.md)
1212
- [Building drivers](how_to/building_drivers.md)
13+
- [Combining Rust `std` with `uefi`](how_to/rust-std.md)
1314
- [Concepts](concepts/introduction.md)
1415
- [Boot Stages](concepts/boot_stages.md)
1516
- [Tables](concepts/tables.md)

book/src/how_to/rust-std.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Combining Rust `std` with `uefi`
2+
3+
## TL;DR
4+
5+
In Mid-2024, we recommend to stick to our normal guide. Use this document as
6+
guide and outlook for the future of UEFI and Rust.
7+
8+
## About
9+
10+
Programs created with the `uefi` crate are typically created with `#![no_std]`
11+
and `#![no_main]`. A `#![no_std]` crate can use the `core` and `alloc` parts of
12+
Rust's standard library, but not `std`. A `#![no_std]` executable does not use
13+
the standard main entry point, and must define its own entry point; `uefi`
14+
provides the `#[entry]` macro for this purpose.
15+
16+
Rust has added partial support for building UEFI executables without
17+
`#![no_std]` and `#![no_main]`, thus, the standard way. Some functionality
18+
requires a nightly toolchain, they are gated by the `uefi_std` feature (Rust
19+
language feature, not `uefi` crate feature). Follow the
20+
[tracking issue](https://github.com/rust-lang/rust/issues/100499) for details.
21+
22+
## Code Example
23+
24+
Please refer to [`<repo>/uefi-std-example`](/uefi-std-example/README.md) to
25+
see a specific example. The relevant `main.rs` looks as follows:
26+
27+
```rust
28+
{{#include ../../../uefi-std-example/src/main.rs}}
29+
```

0 commit comments

Comments
 (0)