float_format/lib.rs
1//! # Float Format
2//!
3//! This is a crate for customizing the format of floating point numbers.
4//! This crate is still work in progress, many features are still to be added.
5//!
6//! So far everything is unstable.
7//!
8//! ## Example
9//!
10//! ```rust
11//! use float_format::*;
12//!
13//! fn main() {
14//! // Create with a custom format and parse from a string.
15//! let float = Float::from_str(
16//! Format::new_ieee_excess(16, 64),
17//! "123456.789012345",
18//! ).unwrap();
19//!
20//! // Format the float with custom precision.
21//! assert_eq!(format!("{:.8}", float), "123456.78901234");
22//!
23//! // Convert from primitive float types.
24//! assert_eq!(Float::from(0.2f32).to_f32(), 0.2f32);
25//! assert_eq!(Float::from(0.2f64).to_f64(), 0.2f64);
26//! }
27//! ```
28
29mod format;
30pub use format::Format;
31
32mod float;
33pub use float::Float;
34
35mod components;
36pub use components::Components;
37
38mod utils;
39pub use utils::*;
40
41pub mod error;