> module
std::io
console I/O
std::io prints formatted text to stdout and stderr. Format strings use {} as placeholders, replaced by the next argument's display form, and {:x} or {:X} for an integer in hex; see xur.std.fmt(7).
When no arguments follow the format string it is printed as is, so io::println("{}") prints {}.
std::io::c colours text for a terminal.
> functions
> types
A recoverable I/O error. Shared across the I/O modules (`std::fs`, `std::net`, `std::path`, …) so a script handles one error type; match it as `Err(io::Error::NotFound)` etc. Build one with `io::Error::from(std::io::Error)`.
| Error::NotFound | |
| Error::PermissionDenied | |
| Error::AlreadyExists | |
| Error::InvalidInput | |
| Error::UnexpectedEof | |
| Error::Interrupted | |
| Error::Other(str) | Any other I/O error, carrying its message. |
> functions
A format string with more placeholders than arguments, more arguments than placeholders, or an unmatched brace is a runtime error.
> errors
io::Error is the shared, matchable error type for the I/O modules (std::fs, std::net, std::path, ...), so a script handles one error type across them. Variants: NotFound, PermissionDenied, AlreadyExists, InvalidInput, UnexpectedEof, Interrupted, and Other(str) (any other error, with its message). Match it as, e.g., Err(io::Error::NotFound).
> examples
use std::io;
use std::io::c;
fn main() {
io::println("Hello, {}!", "world");
io::println("{} + {} = {}", 1, 2, 3);
io::println("{{{}}}", "braced"); // {braced}
io::eprintln("{}", c::red("something went wrong"));
}