pub fn extract_typ_mod(typ_mod: &[u64]) -> Result<Option<u8>, anyhow::Error> {
    let max_precision = u8::try_from(NUMERIC_DATUM_MAX_PRECISION).unwrap();
    let typ_mod = util::extract_typ_mod::<u8>(
        "numeric",
        &typ_mod,
        &[("precision", 1, max_precision), ("scale", 0, max_precision)],
    )?;

    // Poor man's VecDeque
    Ok(match typ_mod.len() {
        0 | 1 => None,
        2 => {
            let precision = typ_mod[0];
            let scale = typ_mod[1];
            if scale > precision {
                bail!(
                    "numeric scale {} must be between 0 and precision {}",
                    scale,
                    precision
                );
            }
            Some(scale)
        }
        _ => unreachable!(),
    })
}
/// Validates the typ_mod is valid for numeric type and returns a specified
/// scale is appropriate (we ignore the specified precision).
Validates the typ_mod is valid for numeric type and returns a specified
scale is appropriate (we ignore the specified precision).
Validates the typ_mod is valid for numeric type and returns a specified scale is appropriate ( we ignore the specified precision ) .
pub fn extract_typ_mod(typ_mod: &[u64]) -> Result<Option<u8>, anyhow::Error> {
    let max_precision = u8::try_from(NUMERIC_DATUM_MAX_PRECISION).unwrap();
    let typ_mod = util::extract_typ_mod::<u8>(
        "numeric",
        &typ_mod,
        &[("precision", 1, max_precision), ("scale", 0, max_precision)],
    )?;
    // Poor man's VecDeque
    Ok(match typ_mod.len() {
        0 | 1 => None,
        2 => {
            let precision = typ_mod[0];
            let scale = typ_mod[1];
            if scale > precision {
                bail!(
                    "numeric scale {} must be between 0 and precision {}",
                    scale,
                    precision
                );
            }
            Some(scale)
        }
        _ => unreachable!(),
    })
}
pub fn extract_typ_mod ( typ_mod : & [ u64 ] ) -> Result < Option < u8 > , anyhow :: Error > { let max_precision = u8 :: try_from ( NUMERIC_DATUM_MAX_PRECISION ) . unwrap ( ) ; let typ_mod = util :: extract_typ_mod :: < u8 > ( " " , & typ_mod , & [ ( " " , 1 , max_precision ) , ( " " , 0 , max_precision ) ] , ) ? ; // Poor man's VecDeque Ok ( match typ_mod . len ( ) { 0 | 1 => None , 2 => { let precision = typ_mod [ 0 ] ; let scale = typ_mod [ 1 ] ; if scale > precision { bail ! ( " " scale precision ) ; } Some ( scale ) } _ => unreachable ! ( ) , } ) }
Validates the typ_mod is valid for numeric type and returns a specified
scale is appropriate (we ignore the specified precision).
Validates the typ_mod is valid for numeric type and returns a specified scale is appropriate ( we ignore the specified precision ) .
typ_mod
&[u64]
typ_mod
&[u64]