expression
Distinguish a simple grayscale average from luminance
A simple teaching grayscale conversion averages three encoded channel values. Widen before addition to prevent u8 overflow. The result uses integer truncation. Actual perceived brightness depends on color space and transfer function; this average is not a standard luminance conversion. Expected result (NOT RUN): red: 85, white: 255 Common mistake: Summing channels in u8 or labeling an unweighted encoded average as luminance. Static Rust example; not a verified ByteMind executable assessment.
Formal Syntax & Structure
rust syntaxrust
(u16::from(r) + u16::from(g) + u16::from(b)) / 3Working Example
Example Snippetrust
fn gray([r,g,b]: [u8;3]) -> u8 { ((u16::from(r) + u16::from(g) + u16::from(b)) / 3) as u8}fn main() { println!("red: {}, white: {}", gray([255,0,0]), gray([255,255,255]));}