renderer.rs

338 B · rust · 9 lines

1use std::collections::HashMap;23/// Appends the value's glyph to the row, or its digits when no glyph is mapped.4pub fn push_glyph(row: &mut String, value: u8, glyphs: Option<&HashMap<u8, char>>) {5    match glyphs.and_then(|g| g.get(&value)) {6        Some(&ch) => row.push(ch),7        None => row.push_str(&value.to_string()),8    }9}