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