Skip to main content

rfham_core/
fmt.rs

1//!
2//! Provides ..., a one-line description
3//!
4//! More detailed description
5//!
6//! # Examples
7//!
8//! ```rust
9//! ```
10//!
11
12// use statements here
13
14// ------------------------------------------------------------------------------------------------
15// Public Macros
16// ------------------------------------------------------------------------------------------------
17
18// ------------------------------------------------------------------------------------------------
19// Public Types
20// ------------------------------------------------------------------------------------------------
21
22pub trait Formatter {
23    fn fmt(&self) -> String {
24        self.fmt_with(&FormatterOptions::default())
25    }
26
27    fn fmt_with(&self, options: &FormatterOptions) -> String;
28}
29
30#[derive(Clone, Copy, Debug, Default, PartialEq)]
31pub struct FormatterOptions {
32    precision: Option<usize>,
33}
34
35// ------------------------------------------------------------------------------------------------
36// Public Functions
37// ------------------------------------------------------------------------------------------------
38
39// ------------------------------------------------------------------------------------------------
40// Private Macros
41// ------------------------------------------------------------------------------------------------
42
43// ------------------------------------------------------------------------------------------------
44// Private Types
45// ------------------------------------------------------------------------------------------------
46
47// ------------------------------------------------------------------------------------------------
48// Implementations
49// ------------------------------------------------------------------------------------------------
50
51impl FormatterOptions {
52    pub const fn with_precision(mut self, precision: usize) -> Self {
53        self.precision = Some(precision);
54        self
55    }
56    pub const fn precision(&self) -> Option<usize> {
57        self.precision
58    }
59}
60// ------------------------------------------------------------------------------------------------
61// Private Functions
62// ------------------------------------------------------------------------------------------------
63
64// ------------------------------------------------------------------------------------------------
65// Sub-Modules
66// ------------------------------------------------------------------------------------------------