]> git.lizzy.rs Git - rust.git/blob - src/libcore/fmt/rt.rs
std: Remove i18n/l10n from format!
[rust.git] / src / libcore / fmt / rt.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
17
18 #[cfg(stage0)]
19 use option::Option;
20
21 #[doc(hidden)]
22 pub enum Piece<'a> {
23     String(&'a str),
24     Argument(Argument<'a>),
25 }
26
27 #[doc(hidden)]
28 pub struct Argument<'a> {
29     pub position: Position,
30     pub format: FormatSpec,
31     #[cfg(stage0)]
32     pub method: Option<uint>,
33 }
34
35 #[doc(hidden)]
36 pub struct FormatSpec {
37     pub fill: char,
38     pub align: Alignment,
39     pub flags: uint,
40     pub precision: Count,
41     pub width: Count,
42 }
43
44 /// Possible alignments that can be requested as part of a formatting directive.
45 #[deriving(PartialEq)]
46 pub enum Alignment {
47     /// Indication that contents should be left-aligned.
48     AlignLeft,
49     /// Indication that contents should be right-aligned.
50     AlignRight,
51     /// No alignment was requested.
52     AlignUnknown,
53 }
54
55 #[doc(hidden)]
56 pub enum Count {
57     CountIs(uint), CountIsParam(uint), CountIsNextParam, CountImplied,
58 }
59
60 #[doc(hidden)]
61 pub enum Position {
62     ArgumentNext, ArgumentIs(uint)
63 }
64
65 /// Flags which can be passed to formatting via a directive.
66 ///
67 /// These flags are discovered through the `flags` field of the `Formatter`
68 /// structure. The flag in that structure is a union of these flags into a
69 /// `uint` where each flag's discriminant is the corresponding bit.
70 pub enum Flag {
71     /// A flag which enables number formatting to always print the sign of a
72     /// number.
73     FlagSignPlus,
74     /// Currently not a used flag
75     FlagSignMinus,
76     /// Indicates that the "alternate formatting" for a type should be used.
77     ///
78     /// The meaning of this flag is type-specific.
79     FlagAlternate,
80     /// Indicates that padding should be done with a `0` character as well as
81     /// being aware of the sign to be printed.
82     FlagSignAwareZeroPad,
83 }