fn parse_num(
        toks: &mut Vec<TimeStrToken>,
        n: &str,
        split_nums: bool,
        idx: usize,
    ) -> Result<(), String> {
        if n.is_empty() {
            return Ok(());
        }

        let (first, second) = if n.len() > 2 && split_nums {
            let (first, second) = n.split_at(n.len() - 2);
            (first, Some(second))
        } else {
            (n, None)
        };

        toks.push(TimeStrToken::Num(
            first.parse().map_err(|e| {
                format!(
                    "Unable to tokenize value {} as a number at index {}: {}",
                    first, idx, e
                )
            })?,
            first.len(),
        ));

        if let Some(second) = second {
            toks.push(TimeStrToken::Num(
                second.parse().map_err(|e| {
                    format!(
                        "Unable to tokenize value {} as a number at index {}: {}",
                        second, idx, e
                    )
                })?,
                second.len(),
            ));
        }

        Ok(())
    }
// Takes a string and tries to parse it as a number token and insert it into
// the token list
Takes a string and tries to parse it as a number token and insert it into
the token list
Takes a string and tries to parse it as a number token and insert it into the token list
fn parse_num(
        toks: &mut Vec<TimeStrToken>,
        n: &str,
        split_nums: bool,
        idx: usize,
    ) -> Result<(), String> {
        if n.is_empty() {
            return Ok(());
        }
        let (first, second) = if n.len() > 2 && split_nums {
            let (first, second) = n.split_at(n.len() - 2);
            (first, Some(second))
        } else {
            (n, None)
        };
        toks.push(TimeStrToken::Num(
            first.parse().map_err(|e| {
                format!(
                    "Unable to tokenize value {} as a number at index {}: {}",
                    first, idx, e
                )
            })?,
            first.len(),
        ));
        if let Some(second) = second {
            toks.push(TimeStrToken::Num(
                second.parse().map_err(|e| {
                    format!(
                        "Unable to tokenize value {} as a number at index {}: {}",
                        second, idx, e
                    )
                })?,
                second.len(),
            ));
        }
        Ok(())
    }
fn parse_num ( toks : & mut Vec < TimeStrToken > , n : & str , split_nums : bool , idx : usize , ) -> Result < ( ) , String > { if n . is_empty ( ) { return Ok ( ( ) ) ; } let ( first , second ) = if n . len ( ) > 2 && split_nums { let ( first , second ) = n . split_at ( n . len ( ) - 2 ) ; ( first , Some ( second ) ) } else { ( n , None ) } ; toks . push ( TimeStrToken :: Num ( first . parse ( ) . map_err ( | e | { format ! ( " " first idx e ) } ) ? , first . len ( ) , ) ) ; if let Some ( second ) = second { toks . push ( TimeStrToken :: Num ( second . parse ( ) . map_err ( | e | { format ! ( " " second idx e ) } ) ? , second . len ( ) , ) ) ; } Ok ( ( ) ) }
Takes a string and tries to parse it as a number token and insert it into
the token list
Takes a string and tries to parse it as a number token and insert it into the token list
toks
&mut Vec<TimeStrToken>
n
&str
split_nums
bool
idx
usize
toks
&mut Vec<TimeStrToken>
n
&str
split_nums
bool
idx
usize