Crate lexical[−][src]
Expand description
Fast lexical conversion routines.
Fast lexical conversion routines for both std and no_std environments.
Lexical provides routines to convert numbers to and from decimal
strings. Lexical also supports non-base 10 numbers, with the radix
feature, for both integers and floats. Lexical is simple to use,
and exports up to 10 functions in the high-level API.
Getting Started
extern crate lexical;
// Number to string
lexical::to_string(3.0); // "3.0", always has a fraction suffix.
lexical::to_string(3); // "3"
// String to number.
let i: i32 = lexical::parse("3").unwrap(); // 3, auto-type deduction.
let f: f32 = lexical::parse("3.5").unwrap(); // 3.5
let d = lexical::parse::<f64, _>("3.5"); // Ok(3.5), successful parse.
let d = lexical::parse::<f64, _>("3a"); // Err(Error(_)), failed to parse.
Conversion API
To String
From String
Configuration Settings
Get Configuration
Set Configuration
Structs
Error type for lexical parsing.
Enums
Error code, indicating failure type.
Traits
Trait for numerical types that can be parsed from bytes.
Trait for floating-point types that can be parsed using lossy algorithms from bytes.
Trait for numerical types that can be serialized to bytes.
Functions
Get default character for the exponent symbol.
Get the short representation of an Infinity literal as a byte slice.
Get the long representation of an Infinity literal as a byte slice.
Get string representation of Not a Number as a byte slice.
High-level conversion of decimal-encoded bytes to a number.
High-level lossy conversion of decimal-encoded bytes to a number.
High-level, partial conversion of decimal-encoded bytes to a number.
High-level, partial, lossy conversion of decimal-encoded bytes to a number.
Set the default character for the exponent symbol.
Set the short representation of Infinity from a byte slice.
Set the long representation of Infinity from a byte slice.
Set representation of Not a Number from a byte slice.
High-level conversion of a number to a decimal-encoded string.
Type Definitions
A specialized Result type for lexical operations.