expression
Use Option and Result through the core prelude
Many language-level tools work without heap allocation or an OS. Option, Result and integer methods remain available in a no_std library. Here a parser accepts a single decimal digit and reports failure explicitly. The host test exercises valid and invalid input. Expected host stdout (not executed): Some(7) None Common mistake: Assuming no_std removes ordinary error handling, generics or pattern matching.
Formal Syntax & Structure
rust syntaxrust
#![no_std]; Option<T>; Result<T, E>Working Example
Example Snippetrust
#![no_std]pub fn digit(byte: u8) -> Option<u8> { match byte { b'0'..=b'9' => Some(byte - b'0'), _ => None }}