Skip to content
La3 Docs
Browse docs

Stdlib Reference

The documented surface for core modules: io, fs, os, json, math, bytes, strings, and collections.

I/O, OS, and files

These modules cover the examples that touch the outside world.

  • io.print, io.println, and io.eprintln write values.
  • fs.read and fs.write return Result because disk access can fail.
  • os.args exposes command-line arguments.
  • os.env returns Option<str> because environment variables can be absent.
  • os.exit returns ! because the process does not continue.

Math, bytes, and JSON

These modules are small, focused pieces of vocabulary used heavily in examples.

  • math exposes f64 functions and constants.
  • bytes.to_hex is useful for binary protocols and diagnostics.
  • Hex and base64 decoding return Result because input can be malformed.
  • json.decode::<T> turns external data into typed values and can fail.

String methods

String helpers should make text examples clear while preserving byte-level honesty.

  • len counts bytes.
  • chars gives character-level iteration.
  • split_once returns Option<(str, str)>.
  • parse::<T> returns Result<T> because text may not represent the requested type.

Collection methods

Collection APIs should reveal ownership and failure modes through their signatures.

  • Mutation methods require mutable access.
  • Lookup methods use Option when absence is normal.
  • Higher-order methods make data transforms readable.
  • Methods that preserve order should say so when order matters.