lexical_write_integer/
options.rs1use 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)]
35 pub const unsafe fn build_unchecked(&self) -> Options {
36 Options {}
37 }
38
39 #[inline(always)]
41 pub const fn build(&self) -> Result<Options> {
42 Ok(unsafe { self.build_unchecked() })
44 }
45}
46
47impl Default for OptionsBuilder {
48 #[inline(always)]
49 fn default() -> Self {
50 Self::new()
51 }
52}
53
54#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
68pub struct Options {}
69
70impl Options {
71 #[inline(always)]
73 pub const fn new() -> Self {
74 Self {}
75 }
76
77 #[inline(always)]
79 pub const fn is_valid(&self) -> bool {
80 true
81 }
82
83 #[inline(always)]
87 pub const fn builder() -> OptionsBuilder {
88 OptionsBuilder::new()
89 }
90
91 #[inline(always)]
93 pub const fn rebuild(&self) -> OptionsBuilder {
94 OptionsBuilder {}
95 }
96}
97
98impl Default for Options {
99 #[inline(always)]
100 fn default() -> Self {
101 Self::new()
102 }
103}
104
105impl WriteOptions for Options {
106 #[inline(always)]
107 fn is_valid(&self) -> bool {
108 Self::is_valid(self)
109 }
110
111 #[inline(always)]
112 fn buffer_size<T: FormattedSize, const FORMAT: u128>(&self) -> usize {
113 T::FORMATTED_SIZE
114 }
115}
116
117#[rustfmt::skip]
122pub const STANDARD: Options = Options::new();
123const_assert!(STANDARD.is_valid());