amarao_san

Rust

Моя первая умная функция на расте:

fn is_good_float(u: String) -> Result<(), String>{
   match u.parse::<f32>() {
       Ok(num) if num < 0.01 => {Err("too small".to_string())},
       Ok(num) if !num.is_normal() => {Err(u)},
       Ok(_) => {Ok(())},
       Err(message) => Err(message.to_string())
   }
}


https://medium.com/journey-to-rust/devtop-command-line-parser-f08b72b02bea


Error

default userpic

Your IP address will be recorded 

When you submit the form an invisible reCAPTCHA check will be performed.
You must follow the Privacy Policy and Google Terms of use.