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.
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.
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.
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
22 // FIXME(#8259): this shouldn't require the unit-value here
24 Argument(Argument<'a>),
28 pub struct Argument<'a> {
29 pub position: Position,
30 pub format: FormatSpec,
31 pub method: Option<&'a Method<'a>>
35 pub struct FormatSpec {
43 /// Possible alignments that can be requested as part of a formatting directive.
44 #[deriving(PartialEq)]
46 /// Indication that contents should be left-aligned.
48 /// Indication that contents should be right-aligned.
50 /// No alignment was requested.
56 CountIs(uint), CountIsParam(uint), CountIsNextParam, CountImplied,
61 ArgumentNext, ArgumentIs(uint)
64 /// Flags which can be passed to formatting via a directive.
66 /// These flags are discovered through the `flags` field of the `Formatter`
67 /// structure. The flag in that structure is a union of these flags into a
68 /// `uint` where each flag's discriminant is the corresponding bit.
70 /// A flag which enables number formatting to always print the sign of a
73 /// Currently not a used flag
75 /// Indicates that the "alternate formatting" for a type should be used.
77 /// The meaning of this flag is type-specific.
79 /// Indicates that padding should be done with a `0` character as well as
80 /// being aware of the sign to be printed.
86 Plural(Option<uint>, &'a [PluralArm<'a>], &'a [Piece<'a>]),
87 Select(&'a [SelectArm<'a>], &'a [Piece<'a>]),
91 pub enum PluralSelector {
92 Keyword(PluralKeyword),
97 pub enum PluralKeyword {
106 pub struct PluralArm<'a> {
107 pub selector: PluralSelector,
108 pub result: &'a [Piece<'a>],
112 pub struct SelectArm<'a> {
113 pub selector: &'a str,
114 pub result: &'a [Piece<'a>],