use crate::*; pub fn format_debug(segments: &[Segment]) -> Result, FormatError> { let mut output = String::new(); for segment in segments { // Find maximum width of all words in the segment. let width = segment.words.iter().map(|w| w.to_string().chars().count()).max().unwrap_or(0); let address = &segment.address; output.push_str(&format!("SEGMENT: 0x{address:>04x}\n")); for word in &segment.words { let string = word.to_string(); let w = width as usize; output.push_str(&format!(" {string:>w$}\n")); } } return Ok(output.into_bytes()); }