fast_float2

Trait FastFloat

Source
pub trait FastFloat: Float {
    // Provided methods
    fn parse_float<S: AsRef<[u8]>>(s: S) -> Result<Self> { ... }
    fn parse_float_partial<S: AsRef<[u8]>>(s: S) -> Result<(Self, usize)> { ... }
}
Expand description

Trait for numerical float types that can be parsed from string.

Provided Methods§

Source

fn parse_float<S: AsRef<[u8]>>(s: S) -> Result<Self>

Parse a decimal number from string into float (full).

§Errors

Will return an error either if the string is not a valid decimal number. or if any characters are left remaining unparsed.

Source

fn parse_float_partial<S: AsRef<[u8]>>(s: S) -> Result<(Self, usize)>

Parse a decimal number from string into float (partial).

This method parses as many characters as possible and returns the resulting number along with the number of digits processed (in case of success, this number is always positive).

§Errors

Will return an error either if the string doesn’t start with a valid decimal number – that is, if no zero digits were processed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FastFloat for f32

Source§

impl FastFloat for f64

Implementors§