fn bit_number(number_string: &str, location: &FileLocation) -> Result<SafasCell, ParseError> {
    // Fetch the characters from the string
    let chrs = number_string.chars().collect::<SmallVec<[_; 8]>>();

    // Format is '1111b8'
    let mut num = 0u128;
    let mut bits = 0u8;

    // Location of the 'b' indicating the number of bits in the number
    let b_pos = chrs.iter()
        .enumerate()
        .filter(|(_pos, chr)| **chr == 'b')
        .map(|(pos, _chr)| pos)
        .nth(0)
        .ok_or_else(|| ParseError::NotABitNumber(location.clone(), number_string.to_string()))?;

    // Parse the bits themselves
    for idx in 0..b_pos {
        num <<= 1;
        match chrs[idx] {
            '0' => { num |= 0; }
            '1' => { num |= 1; }
            _   => { return Err(ParseError::NotABitNumber(location.clone(), number_string.to_string())); }
        }
    }

    // Parse the number of bits
    for idx in (b_pos+1)..chrs.len() {
        bits *= 10;
        if chrs[idx] >= '0' && chrs[idx] <= '9' {
            bits += ((chrs[idx] as u16) - ('0' as u16)) as u8;
        } else {
            return Err(ParseError::InvalidBitCount(location.clone(), number_string.to_string()));
        }
    }

    Ok(SafasCell::Number(SafasNumber::BitNumber(bits, num)))
}
///
/// Parses a bit number (01010b6) as a cell
///
Parses a bit number (01010b6) as a cell
Parses a bit number ( 01010b6 ) as a cell
fn bit_number(number_string: &str, location: &FileLocation) -> Result<SafasCell, ParseError> {
    // Fetch the characters from the string
    let chrs = number_string.chars().collect::<SmallVec<[_; 8]>>();
    // Format is '1111b8'
    let mut num = 0u128;
    let mut bits = 0u8;
    // Location of the 'b' indicating the number of bits in the number
    let b_pos = chrs.iter()
        .enumerate()
        .filter(|(_pos, chr)| **chr == 'b')
        .map(|(pos, _chr)| pos)
        .nth(0)
        .ok_or_else(|| ParseError::NotABitNumber(location.clone(), number_string.to_string()))?;
    // Parse the bits themselves
    for idx in 0..b_pos {
        num <<= 1;
        match chrs[idx] {
            '0' => { num |= 0; }
            '1' => { num |= 1; }
            _   => { return Err(ParseError::NotABitNumber(location.clone(), number_string.to_string())); }
        }
    }
    // Parse the number of bits
    for idx in (b_pos+1)..chrs.len() {
        bits *= 10;
        if chrs[idx] >= '0' && chrs[idx] <= '9' {
            bits += ((chrs[idx] as u16) - ('0' as u16)) as u8;
        } else {
            return Err(ParseError::InvalidBitCount(location.clone(), number_string.to_string()));
        }
    }
    Ok(SafasCell::Number(SafasNumber::BitNumber(bits, num)))
}
fn bit_number ( number_string : & str , location : & FileLocation ) -> Result < SafasCell , ParseError > { // Fetch the characters from the string let chrs = number_string . chars ( ) . collect :: < SmallVec < [ _ ; 8 ] > > ( ) ; // Format is '1111b8' let mut num = 0u128 ; let mut bits = 0u8 ; // Location of the 'b' indicating the number of bits in the number let b_pos = chrs . iter ( ) . enumerate ( ) . filter ( | ( _pos , chr ) | * * chr == 'b' ) . map ( | ( pos , _chr ) | pos ) . nth ( 0 ) . ok_or_else ( | | ParseError :: NotABitNumber ( location . clone ( ) , number_string . to_string ( ) ) ) ? ; // Parse the bits themselves for idx in 0 .. b_pos { num <<= 1 ; match chrs [ idx ] { '0' => { num |= 0 ; } '1' => { num |= 1 ; } _ => { return Err ( ParseError :: NotABitNumber ( location . clone ( ) , number_string . to_string ( ) ) ) ; } } } // Parse the number of bits for idx in ( b_pos + 1 ) .. chrs . len ( ) { bits *= 10 ; if chrs [ idx ] >= '0' && chrs [ idx ] <= '9' { bits += ( ( chrs [ idx ] as u16 ) - ( '0' as u16 ) ) as u8 ; } else { return Err ( ParseError :: InvalidBitCount ( location . clone ( ) , number_string . to_string ( ) ) ) ; } } Ok ( SafasCell :: Number ( SafasNumber :: BitNumber ( bits , num ) ) ) }
Parses a bit number (01010b6) as a cell
Parses a bit number ( 01010b6 ) as a cell
number_string
&str
location
&FileLocation
number_string
&str
location
&FileLocation