]> git.proxmox.com Git - rustc.git/blob - src/libcore/fmt/rt/v1.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / libcore / fmt / rt / v1.rs
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
16 #![allow(missing_debug_implementations)]
17
18 #[derive(Copy, Clone)]
19 pub struct Argument {
20 pub position: Position,
21 pub format: FormatSpec,
22 }
23
24 #[derive(Copy, Clone)]
25 pub struct FormatSpec {
26 pub fill: char,
27 pub align: Alignment,
28 pub flags: u32,
29 pub precision: Count,
30 pub width: Count,
31 }
32
33 /// Possible alignments that can be requested as part of a formatting directive.
34 #[derive(Copy, Clone, PartialEq)]
35 pub enum Alignment {
36 /// Indication that contents should be left-aligned.
37 Left,
38 /// Indication that contents should be right-aligned.
39 Right,
40 /// Indication that contents should be center-aligned.
41 Center,
42 /// No alignment was requested.
43 Unknown,
44 }
45
46 #[derive(Copy, Clone)]
47 pub enum Count {
48 Is(usize),
49 Param(usize),
50 NextParam,
51 Implied,
52 }
53
54 #[derive(Copy, Clone)]
55 pub enum Position {
56 Next,
57 At(usize),
58 }