mirror of
https://github.com/openharmony/third_party_rust_minimal-lexical.git
synced 2026-07-01 09:25:04 -04:00
28eff5d605c2f21070535d26907b4b992fbed748
minimal_lexical
This is a minimal version of rust-lexical, meant to allow efficient round-trip float parsing. This does not implement a correct float parser, however, it will be accurate for round-trip values.
Getting Started
extern crate minimal_lexical;
// Let's say we want to parse "1.2345".
// First, we have an external parser parse all the significant digits
// into a u64 (`12345`), and then we have the exponent adjusted to
// the mantissa (`-4`, since the value is `12345e-4`). Finally,
// we store whether digits were truncated from the mantissa during
// parsing (false).
let float = minimal_lexical::parse_float::<f64>(12345, -4, false);
println!("float={:?}", float); // 1.235
License
Lexical is dual licensed under the Apache 2.0 license as well as the MIT license. See the LICENCE-MIT and the LICENCE-APACHE files for the licenses.
Contributing
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in lexical by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Description
一个高效的浮点数转换库,支持字符串到浮点数和浮点数到字符串的转换。 | A Rust library that provides a minimal and fast implementation of string to number conversions.
Languages
Rust
82.9%
Python
8.7%
Go
7.5%
Shell
0.9%