[][src]Function reader::float

pub fn float(string: String) -> Result<f64, ParseFloatError>

Convert a String to float (f64)

Examples

Basic usage

extern crate reader;
use reader::{input, float};

Reading a float (f64) 

let salary = float(input("Enter your salary: ")).unwrap();
println!("Your salary is: {}", salary);

Reading a float (f32)

let salary = float(input("Enter your salary: ")).unwrap() as f32;
println!("Your salary is: {}", salary);