]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | //! This is an internal module used by the ifmt! runtime. These structures are | |
12 | //! emitted to static arrays to precompile format strings ahead of time. | |
13 | //! | |
14 | //! These definitions are similar to their `ct` equivalents, but differ in that | |
15 | //! these can be statically allocated and are slightly optimized for the runtime | |
54a0048b | 16 | #![allow(missing_debug_implementations)] |
1a4d82fc | 17 | |
c34b1796 | 18 | #[derive(Copy, Clone)] |
85aaf69f | 19 | pub struct Argument { |
1a4d82fc JJ |
20 | pub position: Position, |
21 | pub format: FormatSpec, | |
22 | } | |
23 | ||
c34b1796 | 24 | #[derive(Copy, Clone)] |
1a4d82fc JJ |
25 | pub struct FormatSpec { |
26 | pub fill: char, | |
27 | pub align: Alignment, | |
c34b1796 | 28 | pub flags: u32, |
1a4d82fc JJ |
29 | pub precision: Count, |
30 | pub width: Count, | |
31 | } | |
32 | ||
33 | /// Possible alignments that can be requested as part of a formatting directive. | |
c34b1796 | 34 | #[derive(Copy, Clone, PartialEq)] |
1a4d82fc JJ |
35 | pub enum Alignment { |
36 | /// Indication that contents should be left-aligned. | |
85aaf69f | 37 | Left, |
1a4d82fc | 38 | /// Indication that contents should be right-aligned. |
85aaf69f | 39 | Right, |
1a4d82fc | 40 | /// Indication that contents should be center-aligned. |
85aaf69f | 41 | Center, |
1a4d82fc | 42 | /// No alignment was requested. |
85aaf69f | 43 | Unknown, |
1a4d82fc JJ |
44 | } |
45 | ||
c34b1796 | 46 | #[derive(Copy, Clone)] |
1a4d82fc | 47 | pub enum Count { |
85aaf69f | 48 | Is(usize), |
85aaf69f | 49 | Param(usize), |
85aaf69f | 50 | NextParam, |
85aaf69f | 51 | Implied, |
1a4d82fc JJ |
52 | } |
53 | ||
c34b1796 | 54 | #[derive(Copy, Clone)] |
1a4d82fc | 55 | pub enum Position { |
85aaf69f | 56 | Next, |
b039eaaf | 57 | At(usize), |
1a4d82fc | 58 | } |