]>
git.proxmox.com Git - rustc.git/blob - vendor/ryu/src/lib.rs
1 //! Pure Rust implementation of Ryū, an algorithm to quickly convert floating
2 //! point numbers to decimal strings.
4 //! The PLDI'18 paper [*Ryū: fast float-to-string conversion*][paper] by Ulf
5 //! Adams includes a complete correctness proof of the algorithm. The paper is
6 //! available under the creative commons CC-BY-SA license.
8 //! This Rust implementation is a line-by-line port of Ulf Adams' implementation
9 //! in C, [https://github.com/ulfjack/ryu][upstream]. The [`ryu::raw`][raw]
10 //! module exposes exactly the API and formatting of the C implementation as
11 //! unsafe pure Rust functions. There is additionally a safe API as demonstrated
12 //! in the example code below. The safe API uses the same underlying Ryū
13 //! algorithm but diverges from the formatting of the C implementation to
14 //! produce more human-readable output, for example `0.3` rather than `3E-1`.
16 //! [paper]: https://dl.acm.org/citation.cfm?id=3192369
17 //! [upstream]: https://github.com/ulfjack/ryu
18 //! [raw]: raw/index.html
26 //! let mut buffer = ryu::Buffer::new();
27 //! let printed = buffer.format(1.234);
28 //! assert_eq!(printed, "1.234");
33 #![doc(html_root_url = "https://docs.rs/ryu/0.2.6")]
35 feature
= "cargo-clippy",
38 cyclomatic_complexity
,
39 many_single_char_names
,
40 needless_pass_by_value
,
45 #[cfg(feature = "no-panic")]
46 extern crate no_panic
;
51 #[cfg(not(feature = "small"))]
54 #[cfg(feature = "small")]
60 pub use buffer
::{Buffer, Float}
;
62 /// Unsafe functions that exactly mirror the API of the C implementation of Ryū.
64 pub use d2s
::d2s_buffered_n
;
65 pub use f2s
::f2s_buffered_n
;