Skip to main content

Module io

Module io 

Source
Expand description

I/O Operations for LOGOS Programs

Provides input/output primitives for LOGOS programs including:

  • show: Natural formatting output (primitives without quotes, collections with brackets)
  • print, println, eprintln: Standard output functions
  • read_line: Read a line from stdin

The Showable trait enables custom types to integrate with the show verb.

§Example

use logicaffeine_system::io::{show, println, read_line};

// Natural formatting with show
show(&42);           // Prints: 42
show(&"hello");      // Prints: hello (no quotes)
show(&vec![1, 2, 3]); // Prints: [1, 2, 3]

// Standard output
println("Enter your name:");
let name = read_line();
println(format!("Hello, {}!", name));

Traits§

Showable
Custom trait for LOGOS Show verb - provides clean, natural output. Primitives display without quotes, collections display with brackets.

Functions§

eprintln
flush_stdout
Write everything shown so far. Called wherever stdout’s order against something else becomes observable: before stderr, before input is read, before a program’s own Rust writes to stdout, and when a program fails.
format_currency
A currency hole ({x:$}), rendered exactly as the interpreter’s apply_format_spec: an integer or a float as money with two decimals, an exact integer beyond i64 with an exact .00, and every other value — an exact decimal keeps its own digits — as $ before its own display.
format_fixed
A fixed-precision hole ({x:.2}), rendered exactly as the interpreter’s apply_format_spec: an integer or a float to precision places, and every other value as its own display.
print
println
read_line
show
The Show verb - prints value with natural formatting Takes a reference to avoid moving the value.
show_string
Render any Showable value to a String using the SAME natural formatting as show — used by string interpolation holes so "{s}" matches Show s byte-for-byte, even for types (Sets, user structs) that implement Showable but not std::fmt::Display.