Skip to main content

dfmt/values/
width.rs

1use core::fmt::Write;
2
3use crate::ArgumentKey;
4
5/// Width variants of the specifier.
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum Width {
8    Dynamic(ArgumentKey),
9    Fixed(u16),
10}
11
12impl core::fmt::Display for Width {
13    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
14        match self {
15            Width::Dynamic(argument_key) => {
16                write!(f, "{}", argument_key)?;
17                f.write_char('$')
18            }
19            Width::Fixed(amount) => write!(f, "{}", amount),
20        }
21    }
22}