Rust's standard library (std) provides heap allocation, threads, file I/O, network sockets, and process management. On a microcontroller with 256KB of flash and no OS, none of these exist. #![no_std] tells the compiler: do not link std. Use only core (language primitives) and optionally alloc (heap, if you provide an allocator).
The practical consequence is that every type you use must work without a global allocator. No Vec, no String, no Box. You replace them with fixed-size stack-allocated equivalents from heapless, or you design your data structures to not need dynamic allocation at all.
Why this matters beyond embedded: no_std forces you to reason explicitly about every allocation. Code written in no_std style is often faster, more predictable, and easier to audit than std-dependent code — because there are no hidden allocations, no hidden failures, no runtime surprises.
#![no_std]
#![no_main]
use cortex_m_rt::entry;
use heapless::Vec;
#[entry]
fn main() -> ! {
// Stack-allocated Vec, capacity fixed at compile time
let mut buf: Vec<u8, 64> = Vec::new();
buf.push(0xAA).unwrap();
loop {}
}The ! return type means this function never returns — correct for embedded main, which runs forever.