]> git.lizzy.rs Git - rust.git/blob - library/core/src/fmt/rt/v1.rs
Rollup merge of #92887 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum
[rust.git] / library / core / src / fmt / rt / v1.rs
1 //! This is an internal module used by the ifmt! runtime. These structures are
2 //! emitted to static arrays to precompile format strings ahead of time.
3 //!
4 //! These definitions are similar to their `ct` equivalents, but differ in that
5 //! these can be statically allocated and are slightly optimized for the runtime
6 #![allow(missing_debug_implementations)]
7
8 #[derive(Copy, Clone)]
9 pub struct Argument {
10     pub position: usize,
11     pub format: FormatSpec,
12 }
13
14 #[derive(Copy, Clone)]
15 pub struct FormatSpec {
16     pub fill: char,
17     pub align: Alignment,
18     pub flags: u32,
19     pub precision: Count,
20     pub width: Count,
21 }
22
23 /// Possible alignments that can be requested as part of a formatting directive.
24 #[derive(Copy, Clone, PartialEq, Eq)]
25 pub enum Alignment {
26     /// Indication that contents should be left-aligned.
27     Left,
28     /// Indication that contents should be right-aligned.
29     Right,
30     /// Indication that contents should be center-aligned.
31     Center,
32     /// No alignment was requested.
33     Unknown,
34 }
35
36 /// Used by [width](https://doc.rust-lang.org/std/fmt/#width) and [precision](https://doc.rust-lang.org/std/fmt/#precision) specifiers.
37 #[derive(Copy, Clone)]
38 pub enum Count {
39     /// Specified with a literal number, stores the value
40     Is(usize),
41     /// Specified using `$` and `*` syntaxes, stores the index into `args`
42     Param(usize),
43     /// Not specified
44     Implied,
45 }