lexical_write_integer/
options.rs
1use lexical_util::constants::FormattedSize;
6use lexical_util::options::WriteOptions;
7use lexical_util::result::Result;
8use static_assertions::const_assert;
9
10#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
12pub struct OptionsBuilder {}
13
14impl OptionsBuilder {
15 #[inline(always)]
17 pub const fn new() -> Self {
18 Self {}
19 }
20
21 #[inline(always)]
25 pub const fn is_valid(&self) -> bool {
26 true
27 }
28
29 #[inline(always)]
31 pub const fn build_unchecked(&self) -> Options {
32 Options {}
33 }
34
35 #[inline(always)]
37 pub const fn build(&self) -> Result<Options> {
38 Ok(self.build_unchecked())
39 }
40}
41
42impl Default for OptionsBuilder {
43 #[inline(always)]
44 fn default() -> Self {
45 Self::new()
46 }
47}
48
49#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
63pub struct Options {}
64
65impl Options {
66 #[inline(always)]
68 pub const fn new() -> Self {
69 Self {}
70 }
71
72 #[inline(always)]
74 pub const fn is_valid(&self) -> bool {
75 true
76 }
77
78 #[inline(always)]
82 pub const fn builder() -> OptionsBuilder {
83 OptionsBuilder::new()
84 }
85
86 #[inline(always)]
88 pub const fn rebuild(&self) -> OptionsBuilder {
89 OptionsBuilder {}
90 }
91}
92
93impl Default for Options {
94 #[inline(always)]
95 fn default() -> Self {
96 Self::new()
97 }
98}
99
100impl WriteOptions for Options {
101 #[inline(always)]
102 fn is_valid(&self) -> bool {
103 Self::is_valid(self)
104 }
105
106 #[inline(always)]
107 fn buffer_size<T: FormattedSize, const FORMAT: u128>(&self) -> usize {
108 T::FORMATTED_SIZE
109 }
110}
111
112#[rustfmt::skip]
117pub const STANDARD: Options = Options::new();
118const_assert!(STANDARD.is_valid());