pub fn left(txt: &str, space: usize) -> Option<String> {
    // Determine the width of the characters when displayed
    let len = txt.width();
    // Return None if there is not enough space to fit the string
    if len > space {
        return None;
    }
    // Work out total space needed on the right
    let left_over = space - len;
    // Pad the right hand side
    let right_pad = " ".repeat(left_over);
    // Format and return
    Some(format!("{}{}", txt, right_pad))
}
/// Aligns the text to the left
///
/// This is particularly useful if you want to align columns in a table
///
/// Will return `None` if there is not enough space to fit the text (length of txt > space)
Aligns the text to the left
This is particularly useful if you want to align columns in a table

Will return `None` if there is not enough space to fit the text (length of txt > space)
Aligns the text to the left This is particularly useful if you want to align columns in a table Will return ` None ` if there is not enough space to fit the text ( length of txt > space )
pub fn left(txt: &str, space: usize) -> Option<String> {
    // Determine the width of the characters when displayed
    let len = txt.width();
    // Return None if there is not enough space to fit the string
    if len > space {
        return None;
    }
    // Work out total space needed on the right
    let left_over = space - len;
    // Pad the right hand side
    let right_pad = " ".repeat(left_over);
    // Format and return
    Some(format!("{}{}", txt, right_pad))
}
pub fn left ( txt : & str , space : usize ) -> Option < String > { // Determine the width of the characters when displayed let len = txt . width ( ) ; // Return None if there is not enough space to fit the string if len > space { return None ; } // Work out total space needed on the right let left_over = space - len ; // Pad the right hand side let right_pad = " " . repeat ( left_over ) ; // Format and return Some ( format ! ( " " txt right_pad ) ) }
Aligns the text to the left
This is particularly useful if you want to align columns in a table
Aligns the text to the left This is particularly useful if you want to align columns in a table
txt
&str
space
usize