(index<- ) ./libstd/fmt/rt.rs
git branch: * master 5200215 auto merge of #14035 : alexcrichton/rust/experimental, r=huonw
modified: Fri May 9 13:02:28 2014
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 #![allow(missing_doc)]
18 #![doc(hidden)]
19
20 use option::Option;
21
22 #[cfg(stage0)]
23 pub use fmt::parse::{Alignment, AlignLeft, AlignRight, AlignUnknown};
24 #[cfg(stage0)]
25 pub use fmt::parse::{PluralKeyword, Zero, One, Two, Few, Many};
26 #[cfg(stage0)]
27 pub use fmt::parse::{Flag, FlagSignPlus, FlagSignMinus, FlagSignAwareZeroPad};
28 #[cfg(stage0)]
29 pub use fmt::parse::{FlagAlternate};
30
31 pub enum Piece<'a> {
32 String(&'a str),
33 // FIXME(#8259): this shouldn't require the unit-value here
34 CurrentArgument(()),
35 Argument(Argument<'a>),
36 }
37
38 pub struct Argument<'a> {
39 pub position: Position,
40 pub format: FormatSpec,
41 pub method: Option<&'a Method<'a>>
42 }
43
44 pub struct FormatSpec {
45 pub fill: char,
46 pub align: Alignment,
47 pub flags: uint,
48 pub precision: Count,
49 pub width: Count,
50 }
51
52 #[cfg(not(stage0))]
53 #[deriving(Eq)]
54 pub enum Alignment {
55 AlignLeft,
56 AlignRight,
57 AlignUnknown,
58 }
59
60 pub enum Count {
61 CountIs(uint), CountIsParam(uint), CountIsNextParam, CountImplied,
62 }
63
64 pub enum Position {
65 ArgumentNext, ArgumentIs(uint)
66 }
67
68 #[cfg(not(stage0))]
69 pub enum Flag {
70 FlagSignPlus,
71 FlagSignMinus,
72 FlagAlternate,
73 FlagSignAwareZeroPad,
74 }
75
76 pub enum Method<'a> {
77 Plural(Option<uint>, &'a [PluralArm<'a>], &'a [Piece<'a>]),
78 Select(&'a [SelectArm<'a>], &'a [Piece<'a>]),
79 }
80
81 pub enum PluralSelector {
82 Keyword(PluralKeyword),
83 Literal(uint),
84 }
85
86 pub enum PluralKeyword {
87 Zero,
88 One,
89 Two,
90 Few,
91 Many,
92 }
93
94 pub struct PluralArm<'a> {
95 pub selector: PluralSelector,
96 pub result: &'a [Piece<'a>],
97 }
98
99 pub struct SelectArm<'a> {
100 pub selector: &'a str,
101 pub result: &'a [Piece<'a>],
102 }
libstd/fmt/rt.rs:30:1-30:1 -enum- definition:
pub enum Piece<'a> {
String(&'a str),
// FIXME(#8259): this shouldn't require the unit-value here
references:- 471libstd/cleanup.rs:
libstd/repr.rs:
libstd/unstable/dynamic_lib.rs:
libstd/rt/macros.rs:
libstd/rt/task.rs:
libstd/rt/thread.rs:
libstd/rt/local_heap.rs:
libstd/rt/local_ptr.rs:
libstd/rt/unwind.rs:
libstd/rt/backtrace.rs:
libstd/rt/util.rs:
libstd/rt/stack.rs:
libstd/macros.rs:
libstd/num/mod.rs:
libstd/num/strconv.rs:
libstd/to_str.rs:
libstd/result.rs:
libstd/comm/mod.rs:
libstd/comm/shared.rs:
libstd/comm/sync.rs:
libstd/sync/deque.rs:
libstd/os.rs:
libstd/io/mod.rs:
libstd/io/test.rs:
libstd/io/tempfile.rs:
libstd/io/net/ip.rs:
libstd/io/process.rs:
libstd/io/signal.rs:
libstd/io/stdio.rs:
libstd/path/windows.rs:
libstd/fmt/mod.rs:
libstd/fmt/num.rs:
libstd/fmt/mod.rs:
libstd/fmt/rt.rs:37:1-37:1 -struct- definition:
pub struct Argument<'a> {
pub position: Position,
pub format: FormatSpec,
references:- 363libstd/cleanup.rs:
libstd/repr.rs:
libstd/unstable/dynamic_lib.rs:
libstd/rt/macros.rs:
libstd/rt/task.rs:
libstd/rt/thread.rs:
libstd/rt/local_heap.rs:
libstd/rt/unwind.rs:
libstd/rt/backtrace.rs:
libstd/rt/util.rs:
libstd/rt/stack.rs:
libstd/macros.rs:
libstd/num/strconv.rs:
libstd/to_str.rs:
libstd/result.rs:
libstd/comm/mod.rs:
libstd/comm/shared.rs:
libstd/sync/deque.rs:
libstd/os.rs:
libstd/io/mod.rs:
libstd/io/test.rs:
libstd/io/tempfile.rs:
libstd/io/net/ip.rs:
libstd/io/process.rs:
libstd/io/stdio.rs:
libstd/fmt/rt.rs:
libstd/path/windows.rs:
libstd/fmt/mod.rs:
libstd/fmt/num.rs:
libstd/fmt/mod.rs:
libstd/fmt/rt.rs:43:1-43:1 -struct- definition:
pub struct FormatSpec {
pub fill: char,
pub align: Alignment,
references:- 363libstd/cleanup.rs:
libstd/repr.rs:
libstd/unstable/dynamic_lib.rs:
libstd/rt/macros.rs:
libstd/rt/task.rs:
libstd/rt/thread.rs:
libstd/rt/local_heap.rs:
libstd/rt/unwind.rs:
libstd/rt/backtrace.rs:
libstd/rt/util.rs:
libstd/rt/stack.rs:
libstd/macros.rs:
libstd/num/strconv.rs:
libstd/to_str.rs:
libstd/result.rs:
libstd/comm/mod.rs:
libstd/comm/shared.rs:
libstd/sync/deque.rs:
libstd/os.rs:
libstd/io/mod.rs:
libstd/io/test.rs:
libstd/io/tempfile.rs:
libstd/io/net/ip.rs:
libstd/io/process.rs:
libstd/io/stdio.rs:
libstd/fmt/rt.rs:
libstd/path/windows.rs:
libstd/fmt/mod.rs:
libstd/fmt/num.rs:
libstd/rt/unwind.rs:
libstd/fmt/rt.rs:75:1-75:1 -enum- definition:
pub enum Method<'a> {
Plural(Option<uint>, &'a [PluralArm<'a>], &'a [Piece<'a>]),
Select(&'a [SelectArm<'a>], &'a [Piece<'a>]),
references:- 240: pub format: FormatSpec,
41: pub method: Option<&'a Method<'a>>
42: }
libstd/fmt/mod.rs:
892: fn execute(&mut self, method: &rt::Method, arg: Argument) -> Result {
893: match *method {
libstd/fmt/rt.rs:59:1-59:1 -enum- definition:
pub enum Count {
CountIs(uint), CountIsParam(uint), CountIsNextParam, CountImplied,
}
references:- 348: pub precision: Count,
49: pub width: Count,
50: }
libstd/fmt/mod.rs:
877: fn getcount(&mut self, cnt: &rt::Count) -> Option<uint> {
878: match *cnt {
libstd/fmt/rt.rs:53:16-53:16 -enum- definition:
pub enum Alignment {
AlignLeft,
AlignRight,
references:- 654: pub enum Alignment {
libstd/fmt/mod.rs:
1093: padding: uint,
1094: default: rt::Alignment,
1095: f: |&mut Formatter| -> Result) -> Result {