summary refs log tree commit diff
path: root/src/libstd/fmt
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-03-16 15:59:04 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-03-25 10:12:49 -0700
commita424e84a3e0157f3f0160ae366ba469457cb6295 (patch)
treedf774a0d039b3213a299d4037f6108a911159858 /src/libstd/fmt
parent1f5571abc222520537daa00fc8256040647eec86 (diff)
downloadrust-a424e84a3e0157f3f0160ae366ba469457cb6295.tar.gz
rust-a424e84a3e0157f3f0160ae366ba469457cb6295.zip
libstd: Document the following modules:
* native::io
* std::char
* std::fmt
* std::fmt::parse
* std::io
* std::io::extensions
* std::io::net::ip
* std::io::net::udp
* std::io::net::unix
* std::io::pipe
* std::num
* std::num::f32
* std::num::f64
* std::num::strconv
* std::os
Diffstat (limited to 'src/libstd/fmt')
-rw-r--r--src/libstd/fmt/mod.rs103
-rw-r--r--src/libstd/fmt/parse.rs61
2 files changed, 118 insertions, 46 deletions
diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs
index d3ceba025ea..c2a6510d656 100644
--- a/src/libstd/fmt/mod.rs
+++ b/src/libstd/fmt/mod.rs
@@ -562,51 +562,94 @@ pub struct Arguments<'a> {
 /// When a format is not otherwise specified, types are formatted by ascribing
 /// to this trait. There is not an explicit way of selecting this trait to be
 /// used for formatting, it is only if no other format is specified.
-#[allow(missing_doc)]
-pub trait Show { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait Show {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
 
 /// Format trait for the `b` character
-#[allow(missing_doc)]
-pub trait Bool { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait Bool {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 /// Format trait for the `c` character
-#[allow(missing_doc)]
-pub trait Char { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait Char {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 /// Format trait for the `i` and `d` characters
-#[allow(missing_doc)]
-pub trait Signed { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait Signed {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 /// Format trait for the `u` character
-#[allow(missing_doc)]
-pub trait Unsigned { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait Unsigned {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 /// Format trait for the `o` character
-#[allow(missing_doc)]
-pub trait Octal { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait Octal {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 /// Format trait for the `t` character
-#[allow(missing_doc)]
-pub trait Binary { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait Binary {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 /// Format trait for the `x` character
-#[allow(missing_doc)]
-pub trait LowerHex { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait LowerHex {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 /// Format trait for the `X` character
-#[allow(missing_doc)]
-pub trait UpperHex { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait UpperHex {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 /// Format trait for the `s` character
-#[allow(missing_doc)]
-pub trait String { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait String {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 /// Format trait for the `?` character
-#[allow(missing_doc)]
-pub trait Poly { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait Poly {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 /// Format trait for the `p` character
-#[allow(missing_doc)]
-pub trait Pointer { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait Pointer {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 /// Format trait for the `f` character
-#[allow(missing_doc)]
-pub trait Float { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait Float {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 /// Format trait for the `e` character
-#[allow(missing_doc)]
-pub trait LowerExp { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait LowerExp {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 /// Format trait for the `E` character
-#[allow(missing_doc)]
-pub trait UpperExp { fn fmt(&self, &mut Formatter) -> Result; }
+pub trait UpperExp {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
 
 // FIXME #11938 - UFCS would make us able call the above methods
 // directly Show::show(x, fmt).
diff --git a/src/libstd/fmt/parse.rs b/src/libstd/fmt/parse.rs
index 67088e6f4f8..384e2ff2380 100644
--- a/src/libstd/fmt/parse.rs
+++ b/src/libstd/fmt/parse.rs
@@ -11,16 +11,16 @@
 //! Parsing of format strings
 //!
 //! These structures are used when parsing format strings for the compiler.
-//! Parsing does not currently happen at runtime (structures of std::fmt::rt are
-//! generated instead).
+//! Parsing does not happen at runtime: structures of `std::fmt::rt` are
+//! generated instead.
 
 use prelude::*;
 
 use char;
 use str;
 
-/// A piece is a portion of the format string which represents the next part to
-/// emit. These are emitted as a stream by the `Parser` class.
+/// A piece is a portion of the format string which represents the next part
+/// to emit. These are emitted as a stream by the `Parser` class.
 #[deriving(Eq)]
 pub enum Piece<'a> {
     /// A literal string which should directly be emitted
@@ -65,36 +65,55 @@ pub struct FormatSpec<'a> {
 
 /// Enum describing where an argument for a format can be located.
 #[deriving(Eq)]
-#[allow(missing_doc)]
 pub enum Position<'a> {
-    ArgumentNext, ArgumentIs(uint), ArgumentNamed(&'a str)
+    /// The argument will be in the next position. This is the default.
+    ArgumentNext,
+    /// The argument is located at a specific index.
+    ArgumentIs(uint),
+    /// The argument has a name.
+    ArgumentNamed(&'a str),
 }
 
 /// Enum of alignments which are supported.
 #[deriving(Eq)]
-#[allow(missing_doc)]
-pub enum Alignment { AlignLeft, AlignRight, AlignUnknown }
+pub enum Alignment {
+    /// The value will be aligned to the left.
+    AlignLeft,
+    /// The value will be aligned to the right.
+    AlignRight,
+    /// The value will take on a default alignment.
+    AlignUnknown,
+}
 
-/// Various flags which can be applied to format strings, the meaning of these
+/// Various flags which can be applied to format strings. The meaning of these
 /// flags is defined by the formatters themselves.
 #[deriving(Eq)]
-#[allow(missing_doc)]
 pub enum Flag {
+    /// A `+` will be used to denote positive numbers.
     FlagSignPlus,
+    /// A `-` will be used to denote negative numbers. This is the default.
     FlagSignMinus,
+    /// An alternate form will be used for the value. In the case of numbers,
+    /// this means that the number will be prefixed with the supplied string.
     FlagAlternate,
+    /// For numbers, this means that the number will be padded with zeroes,
+    /// and the sign (`+` or `-`) will precede them.
     FlagSignAwareZeroPad,
 }
 
 /// A count is used for the precision and width parameters of an integer, and
 /// can reference either an argument or a literal integer.
 #[deriving(Eq)]
-#[allow(missing_doc)]
 pub enum Count<'a> {
+    /// The count is specified explicitly.
     CountIs(uint),
+    /// The count is specified by the argument with the given name.
     CountIsName(&'a str),
+    /// The count is specified by the argument at the given index.
     CountIsParam(uint),
+    /// The count is specified by the next parameter.
     CountIsNextParam,
+    /// The count is implied and cannot be explicitly specified.
     CountImplied,
 }
 
@@ -106,8 +125,9 @@ pub enum Method<'a> {
     /// keyword-defined clauses. The meaning of the keywords is defined by the
     /// current locale.
     ///
-    /// An offset is optionally present at the beginning which is used to match
-    /// against keywords, but it is not matched against the literal integers.
+    /// An offset is optionally present at the beginning which is used to
+    /// match against keywords, but it is not matched against the literal
+    /// integers.
     ///
     /// The final element of this enum is the default "other" case which is
     /// always required to be specified.
@@ -139,14 +159,23 @@ pub struct PluralArm<'a> {
     result: ~[Piece<'a>],
 }
 
-/// Enum of the 5 CLDR plural keywords. There is one more, "other", but that is
-/// specially placed in the `Plural` variant of `Method`
+/// Enum of the 5 CLDR plural keywords. There is one more, "other", but that
+/// is specially placed in the `Plural` variant of `Method`.
 ///
 /// http://www.icu-project.org/apiref/icu4c/classicu_1_1PluralRules.html
 #[deriving(Eq, TotalEq, Hash)]
 #[allow(missing_doc)]
 pub enum PluralKeyword {
-    Zero, One, Two, Few, Many
+    /// The plural form for zero objects.
+    Zero,
+    /// The plural form for one object.
+    One,
+    /// The plural form for two objects.
+    Two,
+    /// The plural form for few objects.
+    Few,
+    /// The plural form for many objects.
+    Many,
 }
 
 /// Structure representing one "arm" of the `select` function.