#[derive(Copy, Clone, Debug)]
pub struct PercentOptions {
pub(crate) precision: u8,
pub(crate) force_sign: bool,
pub(crate) fixed_precision: bool,
pub(crate) decimal_separator: char,
}
impl PercentOptions {
#[inline]
pub const fn new() -> Self {
Self {
precision: 1,
force_sign: false,
fixed_precision: false,
decimal_separator: '.',
}
}
#[inline]
pub const fn precision(mut self, n: u8) -> Self {
let n = if n > 6 { 6 } else { n };
self.precision = n;
self
}
#[inline]
pub const fn force_sign(mut self, yes: bool) -> Self {
self.force_sign = yes;
self
}
#[inline]
pub const fn fixed_precision(mut self, yes: bool) -> Self {
self.fixed_precision = yes;
self
}
#[inline]
pub const fn decimal_separator(mut self, sep: char) -> Self {
self.decimal_separator = sep;
self
}
}
impl Default for PercentOptions {
#[inline]
fn default() -> Self {
Self::new()
}
}