Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Standard Library Overview

Flint’s standard library is organized into four layers:

PrefixPurpose
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/*

PackageContents
core/cloneStandard Clone trait for explicit duplication of non-Copy values
core/fmtNo-heap, writer-first formatting. fmt.write(out, "val={}", n)
core/ioReader and Writer traits
core/syncOnceCell<T>, Lazy<T>, atomics, CAS helpers, critical sections
core/errorThe Error type (available in prologue without import)
core/cmpOrdering enum and compare() helper for custom sort APIs
core/embedCompile-time asset embedding: embed.bytes(...), embed.string(...)

std/*

PackageContents
std/timeDuration, Instant, sleep_ms, sleep_us (cross-target)
std/fmtOwned-string formatting: fmt.format("val={}", n) -> Result<string, Error>
std/syncChannels, Mutex<T>, Semaphore
std/textPortable text views, text.Split, and text.Buffer[N]
std/ioBuffered IO, file handles (host targets)
std/fsFilesystem APIs (host targets / SD card)
std/embedHigher-level asset loading on top of core/embed

The Prologue

These names are always in scope without any use:

  • Types: bool, u8 through u64, i8 through i64, 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 string for immutable UTF-8 text views
  • built-in char for Unicode scalar values
  • std/text for split results and fixed-capacity mutable text via text.Buffer[N]

See Text, String, and Char for the current shipped surface.