pub fn parse_int(text: &str) -> Result<i64, IntParseFailReason> {
    //TODO @mark: make sure no leftover chars (no $ at the end)
    match INT_RE.captures(text) {
        None => Err(IntParseFailReason::Invalid),
        Some(captures) => {
            //            // Sign
            //            let sign_str = captures.name("sign").unwrap().as_str();
            //            let sign = if sign_str == "+" || sign_str == "" {
            //                1 // positive
            //            } else {
            //                -1 // negative
            //            };
            // Check if base10 or special
            match captures.name("b10_val") {
                None => {
                    // There is a base provided.
                    if let Some(base) = captures.name("base") {
                        if let Some(value) = captures.name("reb_val") {
                            // TODO: implement
                            panic!(
                                "Do not yet know how to deal with {} in base {}",
                                value.as_str().without_char('_'),
                                base.as_str()
                            )
                        } else {
                            panic!("Expected 'reb_val' match in regex")
                        }
                    } else {
                        panic!("Expected 'base' match in regex")
                    }
                }
                Some(value) => {
                    // This is a 'normal' (base10) value.
                    // TODO: check for over/underflow
                    if value.as_str().len() < text.len() {
                        // Part of `text` did not match the regex, so this input is invalid.
                        return Err(IntParseFailReason::Invalid);
                    }
                    Ok(value.as_str().without_char('_').parse::<i64>().unwrap())
                }
            }
        }
    }
}
/// Convert a String that matches [int_pattern] to an i64 integer. Overflow is possible.
Convert a String that matches [int_pattern] to an i64 integer. Overflow is possible.
Convert a String that matches [ int_pattern ] to an i64 integer . Overflow is possible .
pub fn parse_int(text: &str) -> Result<i64, IntParseFailReason> {
    //TODO @mark: make sure no leftover chars (no $ at the end)
    match INT_RE.captures(text) {
        None => Err(IntParseFailReason::Invalid),
        Some(captures) => {
            //            // Sign
            //            let sign_str = captures.name("sign").unwrap().as_str();
            //            let sign = if sign_str == "+" || sign_str == "" {
            //                1 // positive
            //            } else {
            //                -1 // negative
            //            };
            // Check if base10 or special
            match captures.name("b10_val") {
                None => {
                    // There is a base provided.
                    if let Some(base) = captures.name("base") {
                        if let Some(value) = captures.name("reb_val") {
                            // TODO: implement
                            panic!(
                                "Do not yet know how to deal with {} in base {}",
                                value.as_str().without_char('_'),
                                base.as_str()
                            )
                        } else {
                            panic!("Expected 'reb_val' match in regex")
                        }
                    } else {
                        panic!("Expected 'base' match in regex")
                    }
                }
                Some(value) => {
                    // This is a 'normal' (base10) value.
                    // TODO: check for over/underflow
                    if value.as_str().len() < text.len() {
                        // Part of `text` did not match the regex, so this input is invalid.
                        return Err(IntParseFailReason::Invalid);
                    }
                    Ok(value.as_str().without_char('_').parse::<i64>().unwrap())
                }
            }
        }
    }
}
pub fn parse_int ( text : & str ) -> Result < i64 , IntParseFailReason > { //TODO @mark: make sure no leftover chars (no $ at the end) match INT_RE . captures ( text ) { None => Err ( IntParseFailReason :: Invalid ) , Some ( captures ) => { //            // Sign //            let sign_str = captures.name("sign").unwrap().as_str(); //            let sign = if sign_str == "+" || sign_str == "" { //                1 // positive //            } else { //                -1 // negative //            }; // Check if base10 or special match captures . name ( " " ) { None => { // There is a base provided. if let Some ( base ) = captures . name ( " " ) { if let Some ( value ) = captures . name ( " " ) { // TODO: implement panic ! ( " " value as_str ( ) without_char ( '_' ) base as_str ( ) ) } else { panic ! ( " " ) } } else { panic ! ( " " ) } } Some ( value ) => { // This is a 'normal' (base10) value. // TODO: check for over/underflow if value . as_str ( ) . len ( ) < text . len ( ) { // Part of `text` did not match the regex, so this input is invalid. return Err ( IntParseFailReason :: Invalid ) ; } Ok ( value . as_str ( ) . without_char ( '_' ) . parse :: < i64 > ( ) . unwrap ( ) ) } } } } }
Convert a String that matches [int_pattern] to an i64 integer.
Convert a String that matches [ int_pattern ] to an i64 integer .
text
&str
text
&str