fn input_mob(prompt: &str, default: u64) -> u64 {
        // default is in picoMOB but we need it in MOB
        let mob_default = Decimal::from(default) / Decimal::from_scientific("1e12").unwrap();

        struct CanConvertToMOB;
        impl Validator for CanConvertToMOB {
            type Err = String;
            fn validate(&self, text: &str) -> Result<(), Self::Err> {
                let dec = Decimal::from_str(text).map_err(|err| format!("{}", err))?;
                (dec * Decimal::from_scientific("1e12").unwrap())
                    .to_u64()
                    .ok_or_else(|| "Value too big".to_owned())?;
                Ok(())
            }
        }

        let mob = Input::<Decimal>::new()
            .with_prompt(prompt)
            .default(mob_default)
            .validate_with(CanConvertToMOB)
            .interact()
            .expect("failed getting request code");

        // Convert MOB back to pMOB
        (mob * Decimal::from_scientific("1e12").unwrap())
            .to_u64()
            .expect("failed converting to u64")
    }
/// Read an amount in MOB from the user.
Read an amount in MOB from the user.
Read an amount in MOB from the user .
fn input_mob(prompt: &str, default: u64) -> u64 {
        // default is in picoMOB but we need it in MOB
        let mob_default = Decimal::from(default) / Decimal::from_scientific("1e12").unwrap();
        struct CanConvertToMOB;
        impl Validator for CanConvertToMOB {
            type Err = String;
            fn validate(&self, text: &str) -> Result<(), Self::Err> {
                let dec = Decimal::from_str(text).map_err(|err| format!("{}", err))?;
                (dec * Decimal::from_scientific("1e12").unwrap())
                    .to_u64()
                    .ok_or_else(|| "Value too big".to_owned())?;
                Ok(())
            }
        }
        let mob = Input::<Decimal>::new()
            .with_prompt(prompt)
            .default(mob_default)
            .validate_with(CanConvertToMOB)
            .interact()
            .expect("failed getting request code");
        // Convert MOB back to pMOB
        (mob * Decimal::from_scientific("1e12").unwrap())
            .to_u64()
            .expect("failed converting to u64")
    }
fn input_mob ( prompt : & str , default : u64 ) -> u64 { // default is in picoMOB but we need it in MOB let mob_default = Decimal :: from ( default ) / Decimal :: from_scientific ( " " ) . unwrap ( ) ; struct CanConvertToMOB ; impl Validator for CanConvertToMOB { type Err = String ; fn validate ( & self , text : & str ) -> Result < ( ) , Self :: Err > { let dec = Decimal :: from_str ( text ) . map_err ( | err | format ! ( " " err ) ) ? ; ( dec * Decimal :: from_scientific ( " " ) . unwrap ( ) ) . to_u64 ( ) . ok_or_else ( | | " " . to_owned ( ) ) ? ; Ok ( ( ) ) } } let mob = Input :: < Decimal > :: new ( ) . with_prompt ( prompt ) . default ( mob_default ) . validate_with ( CanConvertToMOB ) . interact ( ) . expect ( " " ) ; // Convert MOB back to pMOB ( mob * Decimal :: from_scientific ( " " ) . unwrap ( ) ) . to_u64 ( ) . expect ( " " ) }
Read an amount in MOB from the user.
Read an amount in MOB from the user .
prompt
&str
default
u64
prompt
&str
default
u64