Skip to main content

ParseNumeric

Trait ParseNumeric 

Source
pub trait ParseNumeric {
    // Required methods
    fn parse_f64(&self) -> Option<f64>;
    fn parse_u64(&self) -> Option<u64>;
}
Expand description

Convenience trait for parsing string numeric fields to native types.

TradeStation returns most numeric values as JSON strings. This trait provides ergonomic parsing on any type with a string field.

§Example

use tradestation_api::market_data::ParseNumeric;

let value = "123.45";
assert_eq!(value.parse_f64(), Some(123.45));
assert_eq!("1000".parse_u64(), Some(1000));
assert_eq!("bad".parse_f64(), None);

Required Methods§

Source

fn parse_f64(&self) -> Option<f64>

Parse this string value as f64, returning None on failure.

Source

fn parse_u64(&self) -> Option<u64>

Parse this string value as u64, returning None on failure.

Implementations on Foreign Types§

Source§

impl ParseNumeric for Option<String>

Source§

impl ParseNumeric for str

Source§

impl ParseNumeric for String

Implementors§