diff --git a/src/libextra/base64.rs b/src/libextra/base64.rs index f26554c42f4f9..c182a005f4b96 100644 --- a/src/libextra/base64.rs +++ b/src/libextra/base64.rs @@ -13,19 +13,19 @@ use std::str; /// Available encoding character sets pub enum CharacterSet { - /// The standard character set (uses '+' and '/') + /// The standard character set (uses `+` and `/`) Standard, - /// The URL safe character set (uses '-' and '_') + /// The URL safe character set (uses `-` and `_`) UrlSafe } -/// Contains configuration parameters for to_base64 +/// Contains configuration parameters for `to_base64`. pub struct Config { /// Character set to use char_set: CharacterSet, - /// True to pad output with '=' characters + /// True to pad output with `=` characters pad: bool, - /// Some(len) to wrap lines at len, None to disable line wrapping + /// `Some(len)` to wrap lines at `len`, `None` to disable line wrapping line_length: Option } diff --git a/src/libextra/bitv.rs b/src/libextra/bitv.rs index 780527e4532cc..323cf5b46b545 100644 --- a/src/libextra/bitv.rs +++ b/src/libextra/bitv.rs @@ -116,7 +116,7 @@ struct BigBitv { } /** - * a mask that has a 1 for each defined bit in the nth element of a big_bitv, + * A mask that has a 1 for each defined bit in the n'th element of a `BigBitv`, * assuming n bits. */ #[inline] @@ -284,7 +284,7 @@ impl Bitv { * Calculates the union of two bitvectors * * Sets `self` to the union of `self` and `v1`. Both bitvectors must be - * the same length. Returns 'true' if `self` changed. + * the same length. Returns `true` if `self` changed. */ #[inline] pub fn union(&mut self, v1: &Bitv) -> bool { self.do_op(Union, v1) } @@ -293,7 +293,7 @@ impl Bitv { * Calculates the intersection of two bitvectors * * Sets `self` to the intersection of `self` and `v1`. Both bitvectors - * must be the same length. Returns 'true' if `self` changed. + * must be the same length. Returns `true` if `self` changed. */ #[inline] pub fn intersect(&mut self, v1: &Bitv) -> bool { @@ -395,7 +395,7 @@ impl Bitv { self.do_op(Difference, v) } - /// Returns true if all bits are 1 + /// Returns `true` if all bits are 1 #[inline] pub fn is_true(&self) -> bool { match self.rep { @@ -417,7 +417,7 @@ impl Bitv { self.iter().invert() } - /// Returns true if all bits are 0 + /// Returns `true` if all bits are 0 pub fn is_false(&self) -> bool { match self.rep { Small(ref b) => b.is_false(self.nbits), @@ -433,9 +433,9 @@ impl Bitv { } /** - * Converts `self` to a vector of uint with the same length. + * Converts `self` to a vector of `uint` with the same length. * - * Each uint in the resulting vector has either value 0u or 1u. + * Each `uint` in the resulting vector has either value `0u` or `1u`. */ pub fn to_vec(&self) -> ~[uint] { vec::from_fn(self.nbits, |x| self.init_to_vec(x)) @@ -443,8 +443,8 @@ impl Bitv { /** * Organise the bits into bytes, such that the first bit in the - * bitv becomes the high-order bit of the first byte. If the - * size of the bitv is not a multiple of 8 then trailing bits + * `Bitv` becomes the high-order bit of the first byte. If the + * size of the `Bitv` is not a multiple of 8 then trailing bits * will be filled-in with false/0 */ pub fn to_bytes(&self) -> ~[u8] { @@ -472,7 +472,7 @@ impl Bitv { } /** - * Transform self into a [bool] by turning each bit into a bool + * Transform `self` into a `[bool]` by turning each bit into a `bool`. */ pub fn to_bools(&self) -> ~[bool] { vec::from_fn(self.nbits, |i| self[i]) @@ -498,7 +498,7 @@ impl Bitv { /** - * Compare a bitvector to a vector of bool. + * Compare a bitvector to a vector of `bool`. * * Both the bitvector and vector must have the same length. */ @@ -519,9 +519,9 @@ impl Bitv { } /** - * Transform a byte-vector into a bitv. Each byte becomes 8 bits, + * Transform a byte-vector into a `Bitv`. Each byte becomes 8 bits, * with the most significant bits of each byte coming first. Each - * bit becomes true if equal to 1 or false if equal to 0. + * bit becomes `true` if equal to 1 or `false` if equal to 0. */ pub fn from_utf8(bytes: &[u8]) -> Bitv { from_fn(bytes.len() * 8, |i| { @@ -532,15 +532,15 @@ pub fn from_utf8(bytes: &[u8]) -> Bitv { } /** - * Transform a [bool] into a bitv by converting each bool into a bit. + * Transform a `[bool]` into a `Bitv` by converting each `bool` into a bit. */ pub fn from_bools(bools: &[bool]) -> Bitv { from_fn(bools.len(), |i| bools[i]) } /** - * Create a bitv of the specified length where the value at each - * index is f(index). + * Create a `Bitv` of the specified length where the value at each + * index is `f(index)`. */ pub fn from_fn(len: uint, f: &fn(index: uint) -> bool) -> Bitv { let mut bitv = Bitv::new(len, false); @@ -571,7 +571,7 @@ fn iterate_bits(base: uint, bits: uint, f: &fn(uint) -> bool) -> bool { return true; } -/// An iterator for Bitv +/// An iterator for `Bitv`. pub struct BitvIterator<'self> { priv bitv: &'self Bitv, priv next_idx: uint, @@ -631,12 +631,12 @@ impl<'self> RandomAccessIterator for BitvIterator<'self> { /// /// It should also be noted that the amount of storage necessary for holding a /// set of objects is proportional to the maximum of the objects when viewed -/// as a uint. +/// as a `uint`. #[deriving(Clone)] pub struct BitvSet { priv size: uint, - // In theory this is a Bitv instead of always a BigBitv, but knowing that + // In theory this is a `Bitv` instead of always a `BigBitv`, but knowing that // there's an array of storage makes our lives a whole lot easier when // performing union/intersection/etc operations priv bitv: BigBitv @@ -861,7 +861,7 @@ impl MutableSet for BitvSet { } impl BitvSet { - /// Visits each of the words that the two bit vectors (self and other) + /// Visits each of the words that the two bit vectors (`self` and `other`) /// both have in common. The three yielded arguments are (bit location, /// w1, w2) where the bit location is the number of bits offset so far, /// and w1/w2 are the words coming from the two vectors self, other. @@ -874,13 +874,13 @@ impl BitvSet { .map(|((i, &w), o_store)| (i * uint::bits, w, o_store[i])) } - /// Visits each word in self or other that extends beyond the other. This + /// Visits each word in `self` or `other` that extends beyond the other. This /// will only iterate through one of the vectors, and it only iterates /// over the portion that doesn't overlap with the other one. /// - /// The yielded arguments are a bool, the bit offset, and a word. The bool - /// is true if the word comes from 'self', and false if it comes from - /// 'other'. + /// The yielded arguments are a `bool`, the bit offset, and a word. The `bool` + /// is true if the word comes from `self`, and `false` if it comes from + /// `other`. fn outlier_iter<'a>(&'a self, other: &'a BitvSet) -> Map<'static, ((uint, &'a uint), uint), (bool, uint, uint), Zip>, Repeat>> { diff --git a/src/libextra/getopts.rs b/src/libextra/getopts.rs index f73c34224ee5f..e6ac1deeb6299 100644 --- a/src/libextra/getopts.rs +++ b/src/libextra/getopts.rs @@ -10,11 +10,11 @@ //! Simple getopt alternative. //! -//! Construct a vector of options, either by using reqopt, optopt, and optflag -//! or by building them from components yourself, and pass them to getopts, -//! along with a vector of actual arguments (not including argv[0]). You'll +//! Construct a vector of options, either by using `reqopt`, `optopt`, and `optflag` +//! or by building them from components yourself, and pass them to `getopts`, +//! along with a vector of actual arguments (not including `argv[0]`). You'll //! either get a failure code back, or a match. You'll have to verify whether -//! the amount of 'free' arguments in the match is what you expect. Use opt_* +//! the amount of 'free' arguments in the match is what you expect. Use `opt_*` //! accessors to get argument values out of the matches object. //! //! Single-character options are expected to appear on the command line with a @@ -27,7 +27,7 @@ //! //! The following example shows simple command line parsing for an application //! that requires an input file to be specified, accepts an optional output -//! file name following -o, and accepts both -h and --help as optional flags. +//! file name following `-o`, and accepts both `-h` and `--help` as optional flags. //! //! ~~~{.rust} //! exter mod extra; diff --git a/src/libextra/num/bigint.rs b/src/libextra/num/bigint.rs index f7462ae29438b..efb39f7c51e02 100644 --- a/src/libextra/num/bigint.rs +++ b/src/libextra/num/bigint.rs @@ -10,10 +10,10 @@ /*! -A Big integer (signed version: BigInt, unsigned version: BigUint). +A Big integer (signed version: `BigInt`, unsigned version: `BigUint`). -A BigUint is represented as an array of BigDigits. -A BigInt is a combination of BigUint and Sign. +A `BigUint` is represented as an array of `BigDigit`s. +A `BigInt` is a combination of `BigUint` and `Sign`. */ #[allow(missing_doc)]; @@ -29,17 +29,17 @@ use std::uint; use std::vec; /** -A BigDigit is a BigUint's composing element. +A `BigDigit` is a `BigUint`'s composing element. -A BigDigit is half the size of machine word size. +A `BigDigit` is half the size of machine word size. */ #[cfg(target_word_size = "32")] pub type BigDigit = u16; /** -A BigDigit is a BigUint's composing element. +A `BigDigit` is a `BigUint`'s composing element. -A BigDigit is half the size of machine word size. +A `BigDigit` is half the size of machine word size. */ #[cfg(target_word_size = "64")] pub type BigDigit = u32; @@ -64,13 +64,13 @@ pub mod BigDigit { #[inline] fn get_lo(n: uint) -> BigDigit { (n & lo_mask) as BigDigit } - /// Split one machine sized unsigned integer into two BigDigits. + /// Split one machine sized unsigned integer into two `BigDigit`s. #[inline] pub fn from_uint(n: uint) -> (BigDigit, BigDigit) { (get_hi(n), get_lo(n)) } - /// Join two BigDigits into one machine sized unsigned integer + /// Join two `BigDigit`s into one machine sized unsigned integer #[inline] pub fn to_uint(hi: BigDigit, lo: BigDigit) -> uint { (lo as uint) | ((hi as uint) << bits) @@ -80,8 +80,8 @@ pub mod BigDigit { /** A big unsigned integer type. -A BigUint-typed value BigUint { data: @[a, b, c] } represents a number -(a + b * BigDigit::base + c * BigDigit::base^2). +A `BigUint`-typed value `BigUint { data: @[a, b, c] }` represents a number +`(a + b * BigDigit::base + c * BigDigit::base^2)`. */ #[deriving(Clone)] pub struct BigUint { @@ -550,7 +550,7 @@ impl ToStrRadix for BigUint { } impl FromStrRadix for BigUint { - /// Creates and initializes an BigUint. + /// Creates and initializes a `BigUint`. #[inline] fn from_str_radix(s: &str, radix: uint) -> Option { @@ -559,7 +559,7 @@ impl FromStrRadix for BigUint { } impl BigUint { - /// Creates and initializes an BigUint. + /// Creates and initializes a `BigUint`. #[inline] pub fn new(v: ~[BigDigit]) -> BigUint { // omit trailing zeros @@ -571,7 +571,7 @@ impl BigUint { return BigUint { data: v }; } - /// Creates and initializes an BigUint. + /// Creates and initializes a `BigUint`. #[inline] pub fn from_uint(n: uint) -> BigUint { match BigDigit::from_uint(n) { @@ -581,13 +581,13 @@ impl BigUint { } } - /// Creates and initializes an BigUint. + /// Creates and initializes a `BigUint`. #[inline] pub fn from_slice(slice: &[BigDigit]) -> BigUint { return BigUint::new(slice.to_owned()); } - /// Creates and initializes an BigUint. + /// Creates and initializes a `BigUint`. pub fn parse_bytes(buf: &[u8], radix: uint) -> Option { let (base, unit_len) = get_radix_base(radix); @@ -615,14 +615,14 @@ impl BigUint { } - /// Converts this BigUint into a uint, failing if the conversion + /// Converts this `BigUint` into a `uint`, failing if the conversion /// would overflow. #[inline] pub fn to_uint(&self) -> uint { self.to_uint_opt().expect("BigUint conversion would overflow uint") } - /// Converts this BigUint into a uint, unless it would overflow. + /// Converts this `BigUint` into a `uint`, unless it would overflow. #[inline] pub fn to_uint_opt(&self) -> Option { match self.data.len() { @@ -633,7 +633,7 @@ impl BigUint { } } - // Converts this BigUint into an int, unless it would overflow. + /// Converts this `BigUint` into an `int`, unless it would overflow. pub fn to_int_opt(&self) -> Option { self.to_uint_opt().and_then(|n| { // If top bit of uint is set, it's too large to convert to @@ -646,7 +646,7 @@ impl BigUint { }) } - /// Converts this BigUint into a BigInt. + /// Converts this `BigUint` into a `BigInt`. #[inline] pub fn to_bigint(&self) -> BigInt { BigInt::from_biguint(Plus, self.clone()) @@ -698,7 +698,7 @@ impl BigUint { return BigUint::new(shifted); } - /// Determines the fewest bits necessary to express the BigUint. + /// Determines the fewest bits necessary to express the `BigUint`. pub fn bits(&self) -> uint { if self.is_zero() { return 0; } let zeros = self.data.last().leading_zeros(); @@ -754,7 +754,7 @@ fn get_radix_base(radix: uint) -> (uint, uint) { } } -/// A Sign is a BigInt's composing element. +/// A Sign is a `BigInt`'s composing element. #[deriving(Eq, Clone)] pub enum Sign { Minus, Zero, Plus } @@ -1117,22 +1117,22 @@ impl FromStrRadix for BigInt { } trait RandBigInt { - /// Generate a random BigUint of the given bit size. + /// Generate a random `BigUint` of the given bit size. fn gen_biguint(&mut self, bit_size: uint) -> BigUint; /// Generate a random BigInt of the given bit size. fn gen_bigint(&mut self, bit_size: uint) -> BigInt; - /// Generate a random BigUint less than the given bound. Fails + /// Generate a random `BigUint` less than the given bound. Fails /// when the bound is zero. fn gen_biguint_below(&mut self, bound: &BigUint) -> BigUint; - /// Generate a random BigUint within the given range. The lower + /// Generate a random `BigUint` within the given range. The lower /// bound is inclusive; the upper bound is exclusive. Fails when /// the upper bound is not greater than the lower bound. fn gen_biguint_range(&mut self, lbound: &BigUint, ubound: &BigUint) -> BigUint; - /// Generate a random BigInt within the given range. The lower + /// Generate a random `BigInt` within the given range. The lower /// bound is inclusive; the upper bound is exclusive. Fails when /// the upper bound is not greater than the lower bound. fn gen_bigint_range(&mut self, lbound: &BigInt, ubound: &BigInt) -> BigInt; @@ -1208,7 +1208,7 @@ impl BigInt { BigInt::from_biguint(sign, BigUint::new(v)) } - /// Creates and initializes an BigInt. + /// Creates and initializes a `BigInt`. #[inline] pub fn from_biguint(sign: Sign, data: BigUint) -> BigInt { if sign == Zero || data.is_zero() { @@ -1217,20 +1217,20 @@ impl BigInt { return BigInt { sign: sign, data: data }; } - /// Creates and initializes an BigInt. + /// Creates and initializes a `BigInt`. #[inline] pub fn from_uint(n: uint) -> BigInt { if n == 0 { return Zero::zero(); } return BigInt::from_biguint(Plus, BigUint::from_uint(n)); } - /// Creates and initializes an BigInt. + /// Creates and initializes a `BigInt`. #[inline] pub fn from_slice(sign: Sign, slice: &[BigDigit]) -> BigInt { BigInt::from_biguint(sign, BigUint::from_slice(slice)) } - /// Creates and initializes an BigInt. + /// Creates and initializes a `BigInt`. pub fn parse_bytes(buf: &[u8], radix: uint) -> Option { if buf.is_empty() { return None; } @@ -1244,14 +1244,14 @@ impl BigInt { .map_move(|bu| BigInt::from_biguint(sign, bu)); } - /// Converts this BigInt into a uint, failing if the conversion + /// Converts this `BigInt` into a `uint`, failing if the conversion /// would overflow. #[inline] pub fn to_uint(&self) -> uint { self.to_uint_opt().expect("BigInt conversion would overflow uint") } - /// Converts this BigInt into a uint, unless it would overflow. + /// Converts this `BigInt` into a `uint`, unless it would overflow. #[inline] pub fn to_uint_opt(&self) -> Option { match self.sign { @@ -1261,7 +1261,7 @@ impl BigInt { } } - /// Converts this BigInt into an int, unless it would overflow. + /// Converts this `BigInt` into an `int`, unless it would overflow. pub fn to_int_opt(&self) -> Option { match self.sign { Plus => self.data.to_int_opt(), @@ -1279,14 +1279,14 @@ impl BigInt { } } - /// Converts this BigInt into a BigUint, failing if BigInt is + /// Converts this `BigInt` into a `BigUint`, failing if BigInt is /// negative. #[inline] pub fn to_biguint(&self) -> BigUint { self.to_biguint_opt().expect("negative BigInt cannot convert to BigUint") } - /// Converts this BigInt into a BigUint, if it's not negative. + /// Converts this `BigInt` into a `BigUint`, if it's not negative. #[inline] pub fn to_biguint_opt(&self) -> Option { match self.sign {