fn to_radix_26(mut n: usize, width: usize) -> Option<Vec<u8>> {
    if width == 0 {
        return None;
    }
    // Use the division algorithm to repeatedly compute the quotient
    // and remainder of the number after division by the radix 26. The
    // successive quotients are the digits in radix 26, from most
    // significant to least significant.
    let mut result = vec![];
    for w in (0..width).rev() {
        let divisor = 26_usize.pow(w as u32);
        let (quotient, remainder) = (n / divisor, n % divisor);
        n = remainder;
        // If the quotient is equal to or greater than the radix, that
        // means the number `n` requires a greater width to be able to
        // represent it in radix 26.
        if quotient >= 26 {
            return None;
        }
        result.push(quotient as u8);
    }
    Some(result)
}
/// Convert a radix 10 number to a radix 26 number of the given width.
///
/// `n` is the radix 10 (that is, decimal) number to transform. This
/// function returns a [`Vec`] of unsigned integers representing the
/// digits, with the most significant digit first and the least
/// significant digit last. The returned `Vec` is always of length
/// `width`.
///
/// If the number `n` is too large to represent within `width` digits,
/// then this function returns `None`.
///
/// # Examples
///
/// ```rust,ignore
/// use crate::filenames::to_radix_26;
///
/// assert_eq!(to_radix_26(20, 2), Some(vec![0, 20]));
/// assert_eq!(to_radix_26(26, 2), Some(vec![1, 0]));
/// assert_eq!(to_radix_26(30, 2), Some(vec![1, 4]));
/// ```
Convert a radix 10 number to a radix 26 number of the given width.
`n` is the radix 10 (that is, decimal) number to transform. This
function returns a [`Vec`] of unsigned integers representing the
digits, with the most significant digit first and the least
significant digit last. The returned `Vec` is always of length
`width`.


Convert a radix 10 number to a radix 26 number of the given width . ` n ` is the radix 10 ( that is decimal ) number to transform . This function returns a [ ` Vec ` ] of unsigned integers representing the digits with the most significant digit first and the least significant digit last . The returned ` Vec ` is always of length ` width ` .
fn to_radix_26(mut n: usize, width: usize) -> Option<Vec<u8>> {
    if width == 0 {
        return None;
    }
    // Use the division algorithm to repeatedly compute the quotient
    // and remainder of the number after division by the radix 26. The
    // successive quotients are the digits in radix 26, from most
    // significant to least significant.
    let mut result = vec![];
    for w in (0..width).rev() {
        let divisor = 26_usize.pow(w as u32);
        let (quotient, remainder) = (n / divisor, n % divisor);
        n = remainder;
        // If the quotient is equal to or greater than the radix, that
        // means the number `n` requires a greater width to be able to
        // represent it in radix 26.
        if quotient >= 26 {
            return None;
        }
        result.push(quotient as u8);
    }
    Some(result)
}
fn to_radix_26 ( mut n : usize , width : usize ) -> Option < Vec < u8 > > { if width == 0 { return None ; } // Use the division algorithm to repeatedly compute the quotient // and remainder of the number after division by the radix 26. The // successive quotients are the digits in radix 26, from most // significant to least significant. let mut result = vec ! [ ] ; for w in ( 0 .. width ) . rev ( ) { let divisor = 26_usize . pow ( w as u32 ) ; let ( quotient , remainder ) = ( n / divisor , n % divisor ) ; n = remainder ; // If the quotient is equal to or greater than the radix, that // means the number `n` requires a greater width to be able to // represent it in radix 26. if quotient >= 26 { return None ; } result . push ( quotient as u8 ) ; } Some ( result ) }
Convert a radix 10 number to a radix 26 number of the given width.
Convert a radix 10 number to a radix 26 number of the given width .
n
usize
width
usize
n
usize
width
usize
examples
```rust,ignore
use crate::filenames::to_radix_26.


` ` ` rust ignore use crate :: filenames :: to_radix_26 .