]> git.proxmox.com Git - rustc.git/blob - vendor/ryu/src/lib.rs
New upstream version 1.32.0~beta.2+dfsg1
[rustc.git] / vendor / ryu / src / lib.rs
1 //! Pure Rust implementation of Ryū, an algorithm to quickly convert floating
2 //! point numbers to decimal strings.
3 //!
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.
7 //!
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`.
15 //!
16 //! [paper]: https://dl.acm.org/citation.cfm?id=3192369
17 //! [upstream]: https://github.com/ulfjack/ryu
18 //! [raw]: raw/index.html
19 //!
20 //! # Examples
21 //!
22 //! ```rust
23 //! extern crate ryu;
24 //!
25 //! fn main() {
26 //! let mut buffer = ryu::Buffer::new();
27 //! let printed = buffer.format(1.234);
28 //! assert_eq!(printed, "1.234");
29 //! }
30 //! ```
31
32 #![no_std]
33 #![doc(html_root_url = "https://docs.rs/ryu/0.2.6")]
34 #![cfg_attr(
35 feature = "cargo-clippy",
36 allow(
37 cast_lossless,
38 cyclomatic_complexity,
39 many_single_char_names,
40 needless_pass_by_value,
41 unreadable_literal,
42 )
43 )]
44
45 #[cfg(feature = "no-panic")]
46 extern crate no_panic;
47
48 mod buffer;
49 mod common;
50 mod d2s;
51 #[cfg(not(feature = "small"))]
52 mod d2s_full_table;
53 mod d2s_intrinsics;
54 #[cfg(feature = "small")]
55 mod d2s_small_table;
56 mod digit_table;
57 mod f2s;
58 mod pretty;
59
60 pub use buffer::{Buffer, Float};
61
62 /// Unsafe functions that exactly mirror the API of the C implementation of Ryū.
63 pub mod raw {
64 pub use d2s::d2s_buffered_n;
65 pub use f2s::f2s_buffered_n;
66 }