get_f64_from_str

Function get_f64_from_str 

Source
pub fn get_f64_from_str(
    line: Option<&str>,
    name: &str,
) -> Result<f64, ParseDstvError>
Expand description

Get f64 from string and strips it of any non numeric characters

§arguments

  • line - line to parse
  • name - name of the element

§return

  • f64 - parsed f64

§example

use dstv::get_f64_from_str;
assert_eq!(get_f64_from_str(Some("1.0s"), "test"), Ok(1.0));
assert_eq!(get_f64_from_str(Some("1.0u"), "test"), Ok(1.0));
assert_eq!(get_f64_from_str(Some("1.0o"), "test"), Ok(1.0));
assert_eq!(get_f64_from_str(Some("1.0"), "test"), Ok(1.0));
assert_eq!(get_f64_from_str(None, "test"), Ok(0.0));