Standard Library Overview
Flint’s standard library is organized into four layers:
| Prefix | Purpose |
|---|---|
core/* | Always available. No heap requirement. Works on bare-metal. |
std/* | Higher-level. May require heap. Cross-target where the concept applies. |
micro/* | MCU peripheral APIs. See HAL and Micro Library. |
board/* | Board-specific pin maps, defaults, and convenience constructors. |
The split matters for MCU targets: core/* packages never drag in allocator support. If your program only uses core/* packages, it has no heap dependency.
What Lives Where
core/*
| Package | Contents |
|---|---|
core/clone | Standard Clone trait for explicit duplication of non-Copy values |
core/fmt | No-heap, writer-first formatting. fmt.write(out, "val={}", n) |
core/io | Reader and Writer traits |
core/sync | OnceCell<T>, Lazy<T>, atomics, CAS helpers, critical sections |
core/error | The Error type (available in prologue without import) |
core/cmp | Ordering enum and compare() helper for custom sort APIs |
core/embed | Compile-time asset embedding: embed.bytes(...), embed.string(...) |
std/*
| Package | Contents |
|---|---|
std/time | Duration, Instant, sleep_ms, sleep_us (cross-target) |
std/fmt | Owned-string formatting: fmt.format("val={}", n) -> Result<string, Error> |
std/sync | Channels, Mutex<T>, Semaphore |
std/text | Portable text views, text.Split, and text.Buffer[N] |
std/io | Buffered IO, file handles (host targets) |
std/fs | Filesystem APIs (host targets / SD card) |
std/embed | Higher-level asset loading on top of core/embed |
The Prologue
These names are always in scope without any use:
- Types:
bool,u8throughu64,i8throughi64,usize,isize,f32,char,string,never,() - Generic types:
Option<T>,Result<T, E>,List<T>,Deque<T>,Map<K, V>,Set<T>,slice<T>,mut slice<T> - Variants:
Some,None,Ok,Err - Literals:
true,false - Functions:
assert,fatal,fatal_error,unreachable - Types:
Error - Traits:
Clone
Everything else requires a use.
Heap Policy
Heap-backed types (List<T>, Map<K, V>, Set<T>, string, etc.) only link allocator support when actually used. Programs that stay in core/* and use only fixed arrays, slices, and stack values pay no heap cost.
When heap support is needed, the compiler links one official allocator for the selected target. On MCUs, the heap is a fixed RAM region configured in the target profile.
Allocation failure returns Err(...), not a silent crash. APIs that may allocate return Result.
Text Today
Flint’s portable text model is already split cleanly:
- built-in
stringfor immutable UTF-8 text views - built-in
charfor Unicode scalar values std/textfor split results and fixed-capacity mutable text viatext.Buffer[N]