1cbd624adSopenharmony_ci//! Fast, minimal float-parsing algorithm. 2cbd624adSopenharmony_ci//! 3cbd624adSopenharmony_ci//! minimal-lexical has a simple, high-level API with a single 4cbd624adSopenharmony_ci//! exported function: [`parse_float`]. 5cbd624adSopenharmony_ci//! 6cbd624adSopenharmony_ci//! [`parse_float`] expects a forward iterator for the integer 7cbd624adSopenharmony_ci//! and fraction digits, as well as a parsed exponent as an [`i32`]. 8cbd624adSopenharmony_ci//! 9cbd624adSopenharmony_ci//! For more examples, please see [simple-example](https://github.com/Alexhuszagh/minimal-lexical/blob/master/examples/simple.rs). 10cbd624adSopenharmony_ci//! 11cbd624adSopenharmony_ci//! EXAMPLES 12cbd624adSopenharmony_ci//! -------- 13cbd624adSopenharmony_ci//! 14cbd624adSopenharmony_ci//! ``` 15cbd624adSopenharmony_ci//! extern crate minimal_lexical; 16cbd624adSopenharmony_ci//! 17cbd624adSopenharmony_ci//! // Let's say we want to parse "1.2345". 18cbd624adSopenharmony_ci//! // First, we need an external parser to extract the integer digits ("1"), 19cbd624adSopenharmony_ci//! // the fraction digits ("2345"), and then parse the exponent to a 32-bit 20cbd624adSopenharmony_ci//! // integer (0). 21cbd624adSopenharmony_ci//! // Warning: 22cbd624adSopenharmony_ci//! // -------- 23cbd624adSopenharmony_ci//! // Please note that leading zeros must be trimmed from the integer, 24cbd624adSopenharmony_ci//! // and trailing zeros must be trimmed from the fraction. This cannot 25cbd624adSopenharmony_ci//! // be handled by minimal-lexical, since we accept iterators. 26cbd624adSopenharmony_ci//! let integer = b"1"; 27cbd624adSopenharmony_ci//! let fraction = b"2345"; 28cbd624adSopenharmony_ci//! let float: f64 = minimal_lexical::parse_float(integer.iter(), fraction.iter(), 0); 29cbd624adSopenharmony_ci//! println!("float={:?}", float); // 1.235 30cbd624adSopenharmony_ci//! ``` 31cbd624adSopenharmony_ci//! 32cbd624adSopenharmony_ci//! [`parse_float`]: fn.parse_float.html 33cbd624adSopenharmony_ci//! [`i32`]: https://doc.rust-lang.org/stable/std/primitive.i32.html 34cbd624adSopenharmony_ci 35cbd624adSopenharmony_ci// FEATURES 36cbd624adSopenharmony_ci 37cbd624adSopenharmony_ci// We want to have the same safety guarantees as Rust core, 38cbd624adSopenharmony_ci// so we allow unused unsafe to clearly document safety guarantees. 39cbd624adSopenharmony_ci#![allow(unused_unsafe)] 40cbd624adSopenharmony_ci#![cfg_attr(feature = "lint", warn(unsafe_op_in_unsafe_fn))] 41cbd624adSopenharmony_ci#![cfg_attr(not(feature = "std"), no_std)] 42cbd624adSopenharmony_ci 43cbd624adSopenharmony_ci#[cfg(all(feature = "alloc", not(feature = "std")))] 44cbd624adSopenharmony_ciextern crate alloc; 45cbd624adSopenharmony_ci 46cbd624adSopenharmony_cipub mod bellerophon; 47cbd624adSopenharmony_cipub mod bigint; 48cbd624adSopenharmony_cipub mod extended_float; 49cbd624adSopenharmony_cipub mod fpu; 50cbd624adSopenharmony_cipub mod heapvec; 51cbd624adSopenharmony_cipub mod lemire; 52cbd624adSopenharmony_cipub mod libm; 53cbd624adSopenharmony_cipub mod mask; 54cbd624adSopenharmony_cipub mod num; 55cbd624adSopenharmony_cipub mod number; 56cbd624adSopenharmony_cipub mod parse; 57cbd624adSopenharmony_cipub mod rounding; 58cbd624adSopenharmony_cipub mod slow; 59cbd624adSopenharmony_cipub mod stackvec; 60cbd624adSopenharmony_cipub mod table; 61cbd624adSopenharmony_ci 62cbd624adSopenharmony_cimod table_bellerophon; 63cbd624adSopenharmony_cimod table_lemire; 64cbd624adSopenharmony_cimod table_small; 65cbd624adSopenharmony_ci 66cbd624adSopenharmony_ci// API 67cbd624adSopenharmony_cipub use self::num::Float; 68cbd624adSopenharmony_cipub use self::parse::parse_float; 69