rulet 2.0.0

A rusty figlet implementation
Documentation
use std::fmt::Display;

use figfont::{FIGcharacter, SubCharacter};

#[derive(Debug, Clone)]
pub struct FIGchar {
    width: usize,
    matrix: Vec<Vec<SubCharacter>>,
}
impl FIGchar {
    /// Gets the inner subcharacters
    pub fn lines(&self) -> &Vec<Vec<SubCharacter>> {
        &self.matrix
    }
    /// gets the width
    pub fn width(&self) -> usize {
        self.width
    }
    /// is a whitespace char?
    pub fn is_whitespace(&self) -> bool {
        self.matrix.iter().all(|line| {
            line.iter().all(|subchar| match subchar {
                SubCharacter::Blank => true,
                SubCharacter::Symbol(s) => s.chars().all(|c| c.is_whitespace()),
            })
        })
    }
    /// Returns the amount of leading space per line, and the last non-space subchar
    pub fn leading_spaces(&self) -> Vec<(usize, SubCharacter)> {
        let mut spaces = vec![(self.width, SubCharacter::Blank); self.matrix.len()];

        for (i, line) in self.matrix.iter().enumerate() {
            for (j, c) in line.iter().enumerate() {
                if *c != SubCharacter::Symbol(" ".to_string()) {
                    spaces[i] = (j, c.clone());
                    break;
                }
            }
        }
        spaces
    }
}
impl Display for FIGchar {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        for line in &self.matrix {
            writeln!(f, "{}", line.join(""))?;
        }
        Ok(())
    }
}
impl From<&FIGcharacter> for FIGchar {
    fn from(value: &FIGcharacter) -> Self {
        FIGchar {
            width: value.width(),
            matrix: value.lines().to_vec(),
        }
    }
}