1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use crate::{formatting::FormattingFlags, parse_utils::StrRawness};

mod errors;

mod parsing;

#[cfg(test)]
mod tests;

pub(crate) use self::errors::{ParseError, ParseErrorKind};

#[derive(Debug, PartialEq)]
pub(crate) struct FormatStr {
    pub(crate) list: Vec<FmtStrComponent>,
}

#[derive(Debug, PartialEq)]
pub(crate) enum FmtStrComponent {
    Str(String, StrRawness),
    Arg(FmtArg),
}

/// An argument in the format string eg: `"{foo:?}"`
#[derive(Debug, PartialEq)]
pub(crate) struct FmtArg {
    pub(crate) which_arg: WhichArg,
    pub(crate) formatting: FormattingFlags,
    pub(crate) rawness: StrRawness,
}

#[derive(Debug, PartialEq)]
pub(crate) enum WhichArg {
    Ident(String),
    Positional(Option<usize>),
}