diff --git a/src/librustc_trans/driver/driver.rs b/src/librustc_trans/driver/driver.rs index b3b68d0c22b38..a5709a0219ba9 100644 --- a/src/librustc_trans/driver/driver.rs +++ b/src/librustc_trans/driver/driver.rs @@ -98,10 +98,8 @@ pub fn compile_input(sess: Session, phase_6_link_output(&sess, &trans, &outputs); } -/** - * The name used for source code that doesn't originate in a file - * (e.g. source from stdin or a string) - */ +/// The name used for source code that doesn't originate in a file +/// (e.g. source from stdin or a string) pub fn anon_src() -> String { "".to_string() } diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index d23e53d2e69bf..8496337acdf16 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -325,15 +325,14 @@ pub enum TransBindingMode { TrByRef, } -/** - * Information about a pattern binding: - * - `llmatch` is a pointer to a stack slot. The stack slot contains a - * pointer into the value being matched. Hence, llmatch has type `T**` - * where `T` is the value being matched. - * - `trmode` is the trans binding mode - * - `id` is the node id of the binding - * - `ty` is the Rust type of the binding */ - #[deriving(Clone)] +/// Information about a pattern binding: +/// - `llmatch` is a pointer to a stack slot. The stack slot contains a +/// pointer into the value being matched. Hence, llmatch has type `T**` +/// where `T` is the value being matched. +/// - `trmode` is the trans binding mode +/// - `id` is the node id of the binding +/// - `ty` is the Rust type of the binding +#[deriving(Clone)] pub struct BindingInfo<'tcx> { pub llmatch: ValueRef, pub trmode: TransBindingMode, @@ -350,12 +349,10 @@ struct ArmData<'p, 'blk, 'tcx: 'blk> { bindings_map: BindingsMap<'tcx> } -/** - * Info about Match. - * If all `pats` are matched then arm `data` will be executed. - * As we proceed `bound_ptrs` are filled with pointers to values to be bound, - * these pointers are stored in llmatch variables just before executing `data` arm. - */ +/// Info about Match. +/// If all `pats` are matched then arm `data` will be executed. +/// As we proceed `bound_ptrs` are filled with pointers to values to be bound, +/// these pointers are stored in llmatch variables just before executing `data` arm. struct Match<'a, 'p: 'a, 'blk: 'a, 'tcx: 'blk> { pats: Vec<&'p ast::Pat>, data: &'a ArmData<'p, 'blk, 'tcx>, diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index e7d1b9726a1b1..e2ce6ee41ee89 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -79,46 +79,38 @@ type Hint = attr::ReprAttr; pub enum Repr<'tcx> { /// C-like enums; basically an int. CEnum(IntType, Disr, Disr), // discriminant range (signedness based on the IntType) - /** - * Single-case variants, and structs/tuples/records. - * - * Structs with destructors need a dynamic destroyedness flag to - * avoid running the destructor too many times; this is included - * in the `Struct` if present. - */ + /// Single-case variants, and structs/tuples/records. + /// + /// Structs with destructors need a dynamic destroyedness flag to + /// avoid running the destructor too many times; this is included + /// in the `Struct` if present. Univariant(Struct<'tcx>, bool), - /** - * General-case enums: for each case there is a struct, and they - * all start with a field for the discriminant. - * - * Types with destructors need a dynamic destroyedness flag to - * avoid running the destructor too many times; the last argument - * indicates whether such a flag is present. - */ + /// General-case enums: for each case there is a struct, and they + /// all start with a field for the discriminant. + /// + /// Types with destructors need a dynamic destroyedness flag to + /// avoid running the destructor too many times; the last argument + /// indicates whether such a flag is present. General(IntType, Vec>, bool), - /** - * Two cases distinguished by a nullable pointer: the case with discriminant - * `nndiscr` must have single field which is known to be nonnull due to its type. - * The other case is known to be zero sized. Hence we represent the enum - * as simply a nullable pointer: if not null it indicates the `nndiscr` variant, - * otherwise it indicates the other case. - */ + /// Two cases distinguished by a nullable pointer: the case with discriminant + /// `nndiscr` must have single field which is known to be nonnull due to its type. + /// The other case is known to be zero sized. Hence we represent the enum + /// as simply a nullable pointer: if not null it indicates the `nndiscr` variant, + /// otherwise it indicates the other case. RawNullablePointer { nndiscr: Disr, nnty: Ty<'tcx>, nullfields: Vec> }, - /** - * Two cases distinguished by a nullable pointer: the case with discriminant - * `nndiscr` is represented by the struct `nonnull`, where the `ptrfield`th - * field is known to be nonnull due to its type; if that field is null, then - * it represents the other case, which is inhabited by at most one value - * (and all other fields are undefined/unused). - * - * For example, `std::option::Option` instantiated at a safe pointer type - * is represented such that `None` is a null pointer and `Some` is the - * identity function. - */ + /// Two cases distinguished by a nullable pointer: the case with discriminant + /// `nndiscr` is represented by the struct `nonnull`, where the `ptrfield`th + /// field is known to be nonnull due to its type; if that field is null, then + /// it represents the other case, which is inhabited by at most one value + /// (and all other fields are undefined/unused). + /// + /// For example, `std::option::Option` instantiated at a safe pointer type + /// is represented such that `None` is a null pointer and `Some` is the + /// identity function. StructWrappedNullablePointer { nonnull: Struct<'tcx>, nndiscr: Disr, @@ -139,11 +131,9 @@ pub struct Struct<'tcx> { pub fields: Vec> } -/** - * Convenience for `represent_type`. There should probably be more or - * these, for places in trans where the `Ty` isn't directly - * available. - */ +/// Convenience for `represent_type`. There should probably be more or +/// these, for places in trans where the `Ty` isn't directly +/// available. pub fn represent_node<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, node: ast::NodeId) -> Rc> { represent_type(bcx.ccx(), node_id_type(bcx, node)) @@ -514,16 +504,14 @@ fn ensure_enum_fits_in_address_space<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, } -/** - * LLVM-level types are a little complicated. - * - * C-like enums need to be actual ints, not wrapped in a struct, - * because that changes the ABI on some platforms (see issue #10308). - * - * For nominal types, in some cases, we need to use LLVM named structs - * and fill in the actual contents in a second pass to prevent - * unbounded recursion; see also the comments in `trans::type_of`. - */ +/// LLVM-level types are a little complicated. +/// +/// C-like enums need to be actual ints, not wrapped in a struct, +/// because that changes the ABI on some platforms (see issue #10308). +/// +/// For nominal types, in some cases, we need to use LLVM named structs +/// and fill in the actual contents in a second pass to prevent +/// unbounded recursion; see also the comments in `trans::type_of`. pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, r: &Repr<'tcx>) -> Type { generic_type_of(cx, r, None, false, false) } @@ -620,12 +608,10 @@ fn struct_llfields<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, st: &Struct<'tcx>, } } -/** - * Obtain a representation of the discriminant sufficient to translate - * destructuring; this may or may not involve the actual discriminant. - * - * This should ideally be less tightly tied to `_match`. - */ +/// Obtain a representation of the discriminant sufficient to translate +/// destructuring; this may or may not involve the actual discriminant. +/// +/// This should ideally be less tightly tied to `_match`. pub fn trans_switch<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>, scrutinee: ValueRef) -> (_match::BranchKind, Option) { @@ -713,12 +699,10 @@ fn load_discr(bcx: Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr) } } -/** - * Yield information about how to dispatch a case of the - * discriminant-like value returned by `trans_switch`. - * - * This should ideally be less tightly tied to `_match`. - */ +/// Yield information about how to dispatch a case of the +/// discriminant-like value returned by `trans_switch`. +/// +/// This should ideally be less tightly tied to `_match`. pub fn trans_case<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr, discr: Disr) -> _match::OptResult<'blk, 'tcx> { match *r { @@ -741,10 +725,8 @@ pub fn trans_case<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr, discr: Disr) } } -/** - * Set the discriminant for a new value of the given case of the given - * representation. - */ +/// Set the discriminant for a new value of the given case of the given +/// representation. pub fn trans_set_discr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>, val: ValueRef, discr: Disr) { match *r { @@ -799,10 +781,8 @@ fn assert_discr_in_range(ity: IntType, min: Disr, max: Disr, discr: Disr) { } } -/** - * The number of fields in a given case; for use when obtaining this - * information from the type or definition is less convenient. - */ +/// The number of fields in a given case; for use when obtaining this +/// information from the type or definition is less convenient. pub fn num_args(r: &Repr, discr: Disr) -> uint { match *r { CEnum(..) => 0, @@ -946,27 +926,25 @@ pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, r: &Repr<'tcx } } -/** - * Construct a constant value, suitable for initializing a - * GlobalVariable, given a case and constant values for its fields. - * Note that this may have a different LLVM type (and different - * alignment!) from the representation's `type_of`, so it needs a - * pointer cast before use. - * - * The LLVM type system does not directly support unions, and only - * pointers can be bitcast, so a constant (and, by extension, the - * GlobalVariable initialized by it) will have a type that can vary - * depending on which case of an enum it is. - * - * To understand the alignment situation, consider `enum E { V64(u64), - * V32(u32, u32) }` on Windows. The type has 8-byte alignment to - * accommodate the u64, but `V32(x, y)` would have LLVM type `{i32, - * i32, i32}`, which is 4-byte aligned. - * - * Currently the returned value has the same size as the type, but - * this could be changed in the future to avoid allocating unnecessary - * space after values of shorter-than-maximum cases. - */ +/// Construct a constant value, suitable for initializing a +/// GlobalVariable, given a case and constant values for its fields. +/// Note that this may have a different LLVM type (and different +/// alignment!) from the representation's `type_of`, so it needs a +/// pointer cast before use. +/// +/// The LLVM type system does not directly support unions, and only +/// pointers can be bitcast, so a constant (and, by extension, the +/// GlobalVariable initialized by it) will have a type that can vary +/// depending on which case of an enum it is. +/// +/// To understand the alignment situation, consider `enum E { V64(u64), +/// V32(u32, u32) }` on Windows. The type has 8-byte alignment to +/// accommodate the u64, but `V32(x, y)` would have LLVM type `{i32, +/// i32, i32}`, which is 4-byte aligned. +/// +/// Currently the returned value has the same size as the type, but +/// this could be changed in the future to avoid allocating unnecessary +/// space after values of shorter-than-maximum cases. pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, r: &Repr<'tcx>, discr: Disr, vals: &[ValueRef]) -> ValueRef { match *r { @@ -1019,9 +997,7 @@ pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, r: &Repr<'tcx>, discr } } -/** - * Compute struct field offsets relative to struct begin. - */ +/// Compute struct field offsets relative to struct begin. fn compute_struct_field_offsets<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, st: &Struct<'tcx>) -> Vec { let mut offsets = vec!(); @@ -1040,16 +1016,14 @@ fn compute_struct_field_offsets<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, offsets } -/** - * Building structs is a little complicated, because we might need to - * insert padding if a field's value is less aligned than its type. - * - * Continuing the example from `trans_const`, a value of type `(u32, - * E)` should have the `E` at offset 8, but if that field's - * initializer is 4-byte aligned then simply translating the tuple as - * a two-element struct will locate it at offset 4, and accesses to it - * will read the wrong memory. - */ +/// Building structs is a little complicated, because we might need to +/// insert padding if a field's value is less aligned than its type. +/// +/// Continuing the example from `trans_const`, a value of type `(u32, +/// E)` should have the `E` at offset 8, but if that field's +/// initializer is 4-byte aligned then simply translating the tuple as +/// a two-element struct will locate it at offset 4, and accesses to it +/// will read the wrong memory. fn build_const_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, st: &Struct<'tcx>, vals: &[ValueRef]) -> Vec { @@ -1130,13 +1104,11 @@ pub fn const_get_discrim(ccx: &CrateContext, r: &Repr, val: ValueRef) } } -/** - * Extract a field of a constant value, as appropriate for its - * representation. - * - * (Not to be confused with `common::const_get_elt`, which operates on - * raw LLVM-level structs and arrays.) - */ +/// Extract a field of a constant value, as appropriate for its +/// representation. +/// +/// (Not to be confused with `common::const_get_elt`, which operates on +/// raw LLVM-level structs and arrays.) pub fn const_get_field(ccx: &CrateContext, r: &Repr, val: ValueRef, _discr: Disr, ix: uint) -> ValueRef { match *r { diff --git a/src/librustc_trans/trans/basic_block.rs b/src/librustc_trans/trans/basic_block.rs index 35afe7ac55e0d..328c8e616c40b 100644 --- a/src/librustc_trans/trans/basic_block.rs +++ b/src/librustc_trans/trans/basic_block.rs @@ -17,9 +17,7 @@ pub struct BasicBlock(pub BasicBlockRef); pub type Preds<'a> = Map<'a, Value, BasicBlock, Filter<'a, Value, Users>>; -/** - * Wrapper for LLVM BasicBlockRef - */ +/// Wrapper for LLVM BasicBlockRef impl BasicBlock { pub fn get(&self) -> BasicBlockRef { let BasicBlock(v) = *self; v diff --git a/src/librustc_trans/trans/datum.rs b/src/librustc_trans/trans/datum.rs index 354a607220715..de7924b27eab0 100644 --- a/src/librustc_trans/trans/datum.rs +++ b/src/librustc_trans/trans/datum.rs @@ -31,12 +31,10 @@ use util::ppaux::{ty_to_string}; use std::fmt; use syntax::ast; -/** - * A `Datum` encapsulates the result of evaluating an expression. It - * describes where the value is stored, what Rust type the value has, - * whether it is addressed by reference, and so forth. Please refer - * the section on datums in `doc.rs` for more details. - */ +/// A `Datum` encapsulates the result of evaluating an expression. It +/// describes where the value is stored, what Rust type the value has, +/// whether it is addressed by reference, and so forth. Please refer +/// the section on datums in `doc.rs` for more details. #[deriving(Clone)] pub struct Datum<'tcx, K> { /// The llvm value. This is either a pointer to the Rust value or @@ -190,25 +188,19 @@ fn add_rvalue_clean<'a, 'tcx>(mode: RvalueMode, pub trait KindOps { - /** - * Take appropriate action after the value in `datum` has been - * stored to a new location. - */ + /// Take appropriate action after the value in `datum` has been + /// stored to a new location. fn post_store<'blk, 'tcx>(&self, bcx: Block<'blk, 'tcx>, val: ValueRef, ty: Ty<'tcx>) -> Block<'blk, 'tcx>; - /** - * True if this mode is a reference mode, meaning that the datum's - * val field is a pointer to the actual value - */ + /// True if this mode is a reference mode, meaning that the datum's + /// val field is a pointer to the actual value fn is_by_ref(&self) -> bool; - /** - * Converts to an Expr kind - */ + /// Converts to an Expr kind fn to_expr_kind(self) -> Expr; } @@ -361,14 +353,12 @@ impl<'tcx> Datum<'tcx, Rvalue> { } } -/** - * Methods suitable for "expr" datums that could be either lvalues or - * rvalues. These include coercions into lvalues/rvalues but also a number - * of more general operations. (Some of those operations could be moved to - * the more general `impl Datum`, but it's convenient to have them - * here since we can `match self.kind` rather than having to implement - * generic methods in `KindOps`.) - */ +/// Methods suitable for "expr" datums that could be either lvalues or +/// rvalues. These include coercions into lvalues/rvalues but also a number +/// of more general operations. (Some of those operations could be moved to +/// the more general `impl Datum`, but it's convenient to have them +/// here since we can `match self.kind` rather than having to implement +/// generic methods in `KindOps`.) impl<'tcx> Datum<'tcx, Expr> { fn match_kind(self, if_lvalue: |Datum<'tcx, Lvalue>| -> R, @@ -494,12 +484,10 @@ impl<'tcx> Datum<'tcx, Expr> { } -/** - * Methods suitable only for lvalues. These include the various - * operations to extract components out of compound data structures, - * such as extracting the field from a struct or a particular element - * from an array. - */ +/// Methods suitable only for lvalues. These include the various +/// operations to extract components out of compound data structures, +/// such as extracting the field from a struct or a particular element +/// from an array. impl<'tcx> Datum<'tcx, Lvalue> { pub fn to_llref(self) -> ValueRef { /*! @@ -542,9 +530,7 @@ impl<'tcx> Datum<'tcx, Lvalue> { } } -/** - * Generic methods applicable to any sort of datum. - */ +/// Generic methods applicable to any sort of datum. impl<'tcx, K: KindOps + fmt::Show> Datum<'tcx, K> { pub fn new(val: ValueRef, ty: Ty<'tcx>, kind: K) -> Datum<'tcx, K> { Datum { val: val, ty: ty, kind: kind } diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index 482b318e37202..b39029d3b94c5 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -1377,14 +1377,12 @@ fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, }) } -/** - * Information that `trans_adt` needs in order to fill in the fields - * of a struct copied from a base struct (e.g., from an expression - * like `Foo { a: b, ..base }`. - * - * Note that `fields` may be empty; the base expression must always be - * evaluated for side-effects. - */ +/// Information that `trans_adt` needs in order to fill in the fields +/// of a struct copied from a base struct (e.g., from an expression +/// like `Foo { a: b, ..base }`. +/// +/// Note that `fields` may be empty; the base expression must always be +/// evaluated for side-effects. pub struct StructBaseInfo<'a, 'tcx> { /// The base expression; will be evaluated after all explicit fields. expr: &'a ast::Expr, @@ -1392,16 +1390,14 @@ pub struct StructBaseInfo<'a, 'tcx> { fields: Vec<(uint, Ty<'tcx>)> } -/** - * Constructs an ADT instance: - * - * - `fields` should be a list of field indices paired with the - * expression to store into that field. The initializers will be - * evaluated in the order specified by `fields`. - * - * - `optbase` contains information on the base struct (if any) from - * which remaining fields are copied; see comments on `StructBaseInfo`. - */ +/// Constructs an ADT instance: +/// +/// - `fields` should be a list of field indices paired with the +/// expression to store into that field. The initializers will be +/// evaluated in the order specified by `fields`. +/// +/// - `optbase` contains information on the base struct (if any) from +/// which remaining fields are copied; see comments on `StructBaseInfo`. pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, ty: Ty<'tcx>, discr: ty::Disr, diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs index 0ff7f3ee71cc6..2c0e4d31d97d0 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/trans/meth.rs @@ -46,12 +46,10 @@ use syntax::codemap::DUMMY_SP; // drop_glue pointer, size, align. static VTABLE_OFFSET: uint = 3; -/** -The main "translation" pass for methods. Generates code -for non-monomorphized methods only. Other methods will -be generated once they are invoked with specific type parameters, -see `trans::base::lval_static_fn()` or `trans::base::monomorphic_fn()`. -*/ +/// The main "translation" pass for methods. Generates code +/// for non-monomorphized methods only. Other methods will +/// be generated once they are invoked with specific type parameters, +/// see `trans::base::lval_static_fn()` or `trans::base::monomorphic_fn()`. pub fn trans_impl(ccx: &CrateContext, name: ast::Ident, impl_items: &[ast::ImplItem], diff --git a/src/librustc_trans/trans/type_.rs b/src/librustc_trans/trans/type_.rs index 0662909e40f5a..8bff7602ddcea 100644 --- a/src/librustc_trans/trans/type_.rs +++ b/src/librustc_trans/trans/type_.rs @@ -35,9 +35,7 @@ macro_rules! ty ( ($e:expr) => ( Type::from_ref(unsafe { $e })) ) -/** - * Wrapper for LLVM TypeRef - */ +/// Wrapper for LLVM TypeRef impl Type { #[inline(always)] pub fn from_ref(r: TypeRef) -> Type { diff --git a/src/librustc_trans/trans/value.rs b/src/librustc_trans/trans/value.rs index 8d74275c92ac7..33ea239412af6 100644 --- a/src/librustc_trans/trans/value.rs +++ b/src/librustc_trans/trans/value.rs @@ -25,9 +25,7 @@ macro_rules! opt_val ( ($e:expr) => ( } )) -/** - * Wrapper for LLVM ValueRef - */ +/// Wrapper for LLVM ValueRef impl Value { /// Returns the native ValueRef pub fn get(&self) -> ValueRef { @@ -127,9 +125,7 @@ impl Value { pub struct Use(UseRef); -/** - * Wrapper for LLVM UseRef - */ +/// Wrapper for LLVM UseRef impl Use { pub fn get(&self) -> UseRef { let Use(v) = *self; v diff --git a/src/libserialize/base64.rs b/src/libserialize/base64.rs index 41feee8257f9c..b7d8885a5f993 100644 --- a/src/libserialize/base64.rs +++ b/src/libserialize/base64.rs @@ -64,21 +64,19 @@ pub trait ToBase64 for Sized? { } impl ToBase64 for [u8] { - /** - * Turn a vector of `u8` bytes into a base64 string. - * - * # Example - * - * ```rust - * extern crate serialize; - * use serialize::base64::{ToBase64, STANDARD}; - * - * fn main () { - * let str = [52,32].to_base64(STANDARD); - * println!("base 64 output: {}", str); - * } - * ``` - */ + /// Turn a vector of `u8` bytes into a base64 string. + /// + /// # Example + /// + /// ```rust + /// extern crate serialize; + /// use serialize::base64::{ToBase64, STANDARD}; + /// + /// fn main () { + /// let str = [52,32].to_base64(STANDARD); + /// println!("base 64 output: {}", str); + /// } + /// ``` fn to_base64(&self, config: Config) -> String { let bytes = match config.char_set { Standard => STANDARD_CHARS, @@ -194,34 +192,32 @@ impl error::Error for FromBase64Error { } impl FromBase64 for str { - /** - * Convert any base64 encoded string (literal, `@`, `&`, or `~`) - * to the byte values it encodes. - * - * You can use the `String::from_utf8` function to turn a `Vec` into a - * string with characters corresponding to those values. - * - * # Example - * - * This converts a string literal to base64 and back. - * - * ```rust - * extern crate serialize; - * use serialize::base64::{ToBase64, FromBase64, STANDARD}; - * - * fn main () { - * let hello_str = b"Hello, World".to_base64(STANDARD); - * println!("base64 output: {}", hello_str); - * let res = hello_str.as_slice().from_base64(); - * if res.is_ok() { - * let opt_bytes = String::from_utf8(res.unwrap()); - * if opt_bytes.is_ok() { - * println!("decoded from base64: {}", opt_bytes.unwrap()); - * } - * } - * } - * ``` - */ + /// Convert any base64 encoded string (literal, `@`, `&`, or `~`) + /// to the byte values it encodes. + /// + /// You can use the `String::from_utf8` function to turn a `Vec` into a + /// string with characters corresponding to those values. + /// + /// # Example + /// + /// This converts a string literal to base64 and back. + /// + /// ```rust + /// extern crate serialize; + /// use serialize::base64::{ToBase64, FromBase64, STANDARD}; + /// + /// fn main () { + /// let hello_str = b"Hello, World".to_base64(STANDARD); + /// println!("base64 output: {}", hello_str); + /// let res = hello_str.as_slice().from_base64(); + /// if res.is_ok() { + /// let opt_bytes = String::from_utf8(res.unwrap()); + /// if opt_bytes.is_ok() { + /// println!("decoded from base64: {}", opt_bytes.unwrap()); + /// } + /// } + /// } + /// ``` #[inline] fn from_base64(&self) -> Result, FromBase64Error> { self.as_bytes().from_base64() diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs index 78859d6778d70..2a3c410ba7c58 100644 --- a/src/libserialize/hex.rs +++ b/src/libserialize/hex.rs @@ -27,21 +27,19 @@ pub trait ToHex for Sized? { static CHARS: &'static[u8] = b"0123456789abcdef"; impl ToHex for [u8] { - /** - * Turn a vector of `u8` bytes into a hexadecimal string. - * - * # Example - * - * ```rust - * extern crate serialize; - * use serialize::hex::ToHex; - * - * fn main () { - * let str = [52,32].to_hex(); - * println!("{}", str); - * } - * ``` - */ + /// Turn a vector of `u8` bytes into a hexadecimal string. + /// + /// # Example + /// + /// ```rust + /// extern crate serialize; + /// use serialize::hex::ToHex; + /// + /// fn main () { + /// let str = [52,32].to_hex(); + /// println!("{}", str); + /// } + /// ``` fn to_hex(&self) -> String { let mut v = Vec::with_capacity(self.len() * 2); for &byte in self.iter() { @@ -95,31 +93,29 @@ impl error::Error for FromHexError { impl FromHex for str { - /** - * Convert any hexadecimal encoded string (literal, `@`, `&`, or `~`) - * to the byte values it encodes. - * - * You can use the `String::from_utf8` function to turn a - * `Vec` into a string with characters corresponding to those values. - * - * # Example - * - * This converts a string literal to hexadecimal and back. - * - * ```rust - * extern crate serialize; - * use serialize::hex::{FromHex, ToHex}; - * - * fn main () { - * let hello_str = "Hello, World".as_bytes().to_hex(); - * println!("{}", hello_str); - * let bytes = hello_str.as_slice().from_hex().unwrap(); - * println!("{}", bytes); - * let result_str = String::from_utf8(bytes).unwrap(); - * println!("{}", result_str); - * } - * ``` - */ + /// Convert any hexadecimal encoded string (literal, `@`, `&`, or `~`) + /// to the byte values it encodes. + /// + /// You can use the `String::from_utf8` function to turn a + /// `Vec` into a string with characters corresponding to those values. + /// + /// # Example + /// + /// This converts a string literal to hexadecimal and back. + /// + /// ```rust + /// extern crate serialize; + /// use serialize::hex::{FromHex, ToHex}; + /// + /// fn main () { + /// let hello_str = "Hello, World".as_bytes().to_hex(); + /// println!("{}", hello_str); + /// let bytes = hello_str.as_slice().from_hex().unwrap(); + /// println!("{}", bytes); + /// let result_str = String::from_utf8(bytes).unwrap(); + /// println!("{}", result_str); + /// } + /// ``` fn from_hex(&self) -> Result, FromHexError> { // This may be an overestimate if there is any whitespace let mut b = Vec::with_capacity(self.len() / 2); diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 649298d9c0818..be6e387ad836d 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -67,31 +67,32 @@ pub enum SignFormat { SignAll, } -/** - * Converts an integral number to its string representation as a byte vector. - * This is meant to be a common base implementation for all integral string - * conversion functions like `to_string()` or `to_str_radix()`. - * - * # Arguments - * - `num` - The number to convert. Accepts any number that - * implements the numeric traits. - * - `radix` - Base to use. Accepts only the values 2-36. - * - `sign` - How to emit the sign. Options are: - * - `SignNone`: No sign at all. Basically emits `abs(num)`. - * - `SignNeg`: Only `-` on negative values. - * - `SignAll`: Both `+` on positive, and `-` on negative numbers. - * - `f` - a callback which will be invoked for each ascii character - * which composes the string representation of this integer - * - * # Return value - * A tuple containing the byte vector, and a boolean flag indicating - * whether it represents a special value like `inf`, `-inf`, `NaN` or not. - * It returns a tuple because there can be ambiguity between a special value - * and a number representation at higher bases. - * - * # Panics - * - Panics if `radix` < 2 or `radix` > 36. - */ +/// Converts an integral number to its string representation as a byte vector. +/// This is meant to be a common base implementation for all integral string +/// conversion functions like `to_string()` or `to_str_radix()`. +/// +/// # Arguments +/// +/// - `num` - The number to convert. Accepts any number that +/// implements the numeric traits. +/// - `radix` - Base to use. Accepts only the values 2-36. +/// - `sign` - How to emit the sign. Options are: +/// - `SignNone`: No sign at all. Basically emits `abs(num)`. +/// - `SignNeg`: Only `-` on negative values. +/// - `SignAll`: Both `+` on positive, and `-` on negative numbers. +/// - `f` - a callback which will be invoked for each ascii character +/// which composes the string representation of this integer +/// +/// # Return value +/// +/// A tuple containing the byte vector, and a boolean flag indicating +/// whether it represents a special value like `inf`, `-inf`, `NaN` or not. +/// It returns a tuple because there can be ambiguity between a special value +/// and a number representation at higher bases. +/// +/// # Panics +/// +/// - Panics if `radix` < 2 or `radix` > 36. fn int_to_str_bytes_common(num: T, radix: uint, sign: SignFormat, f: |u8|) { assert!(2 <= radix && radix <= 36); diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 9b50361ec1f0d..c6554d2ed58e2 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -788,18 +788,16 @@ pub fn homedir() -> Option { _homedir() } -/** - * Returns the path to a temporary directory. - * - * On Unix, returns the value of the 'TMPDIR' environment variable if it is - * set, otherwise for non-Android it returns '/tmp'. If Android, since there - * is no global temporary folder (it is usually allocated per-app), we return - * '/data/local/tmp'. - * - * On Windows, returns the value of, in order, the 'TMP', 'TEMP', - * 'USERPROFILE' environment variable if any are set and not the empty - * string. Otherwise, tmpdir returns the path to the Windows directory. - */ +/// Returns the path to a temporary directory. +/// +/// On Unix, returns the value of the 'TMPDIR' environment variable if it is +/// set, otherwise for non-Android it returns '/tmp'. If Android, since there +/// is no global temporary folder (it is usually allocated per-app), we return +/// '/data/local/tmp'. +/// +/// On Windows, returns the value of, in order, the 'TMP', 'TEMP', +/// 'USERPROFILE' environment variable if any are set and not the empty +/// string. Otherwise, tmpdir returns the path to the Windows directory. pub fn tmpdir() -> Path { return lookup(); @@ -933,16 +931,14 @@ pub fn last_os_error() -> String { static EXIT_STATUS: AtomicInt = INIT_ATOMIC_INT; -/** - * Sets the process exit code - * - * Sets the exit code returned by the process if all supervised tasks - * terminate successfully (without panicking). If the current root task panics - * and is supervised by the scheduler then any user-specified exit status is - * ignored and the process exits with the default panic status. - * - * Note that this is not synchronized against modifications of other threads. - */ +/// Sets the process exit code +/// +/// Sets the exit code returned by the process if all supervised tasks +/// terminate successfully (without panicking). If the current root task panics +/// and is supervised by the scheduler then any user-specified exit status is +/// ignored and the process exits with the default panic status. +/// +/// Note that this is not synchronized against modifications of other threads. pub fn set_exit_status(code: int) { EXIT_STATUS.store(code, SeqCst) } @@ -963,11 +959,9 @@ unsafe fn load_argc_and_argv(argc: int, }) } -/** - * Returns the command line arguments - * - * Returns a list of the command line arguments. - */ +/// Returns the command line arguments +/// +/// Returns a list of the command line arguments. #[cfg(target_os = "macos")] fn real_args_as_bytes() -> Vec> { unsafe { diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index 3fb5ee34356fe..37e0fd6e55d7f 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -33,13 +33,11 @@ use string::String; pub use sys_common::ProcessConfig; -/** - * A value representing a child process. - * - * The lifetime of this value is linked to the lifetime of the actual - * process - the Process destructor calls self.finish() which waits - * for the process to terminate. - */ +/// A value representing a child process. +/// +/// The lifetime of this value is linked to the lifetime of the actual +/// process - the Process destructor calls self.finish() which waits +/// for the process to terminate. pub struct Process { /// The unique id of the process (this should never be negative). pid: pid_t, @@ -263,16 +261,14 @@ impl Process { } } - /** - * Waits for a process to exit and returns the exit code, failing - * if there is no process with the specified id. - * - * Note that this is private to avoid race conditions on unix where if - * a user calls waitpid(some_process.get_id()) then some_process.finish() - * and some_process.destroy() and some_process.finalize() will then either - * operate on a none-existent process or, even worse, on a newer process - * with the same id. - */ + /// Waits for a process to exit and returns the exit code, failing + /// if there is no process with the specified id. + /// + /// Note that this is private to avoid race conditions on unix where if + /// a user calls waitpid(some_process.get_id()) then some_process.finish() + /// and some_process.destroy() and some_process.finalize() will then either + /// operate on a none-existent process or, even worse, on a newer process + /// with the same id. pub fn wait(&self, deadline: u64) -> IoResult { use libc::types::os::arch::extra::DWORD; use libc::consts::os::extra::{ diff --git a/src/libsync/lock.rs b/src/libsync/lock.rs index d6378c2190ece..e27dc124c3a87 100644 --- a/src/libsync/lock.rs +++ b/src/libsync/lock.rs @@ -29,9 +29,7 @@ use rustrt::task::Task; use raw; -/**************************************************************************** - * Poisoning helpers - ****************************************************************************/ +// Poisoning helpers struct PoisonOnFail<'a> { flag: &'a mut bool, @@ -67,9 +65,7 @@ impl<'a> Drop for PoisonOnFail<'a> { } } -/**************************************************************************** - * Condvar - ****************************************************************************/ +// Condvar enum Inner<'a> { InnerMutex(raw::MutexGuard<'a>), @@ -147,10 +143,6 @@ impl<'a> Condvar<'a> { } } -/**************************************************************************** - * Mutex - ****************************************************************************/ - /// A wrapper type which provides synchronized access to the underlying data, of /// type `T`. A mutex always provides exclusive access, and concurrent requests /// will block while the mutex is already locked. @@ -249,10 +241,6 @@ impl<'a, T: Send> DerefMut for MutexGuard<'a, T> { fn deref_mut<'a>(&'a mut self) -> &'a mut T { &mut *self._data } } -/**************************************************************************** - * R/W lock protected lock - ****************************************************************************/ - /// A dual-mode reader-writer lock. The data can be accessed mutably or /// immutably, and immutably-accessing tasks may run concurrently. /// @@ -387,10 +375,6 @@ impl<'a, T: Send + Sync> DerefMut for RWLockWriteGuard<'a, T> { fn deref_mut<'a>(&'a mut self) -> &'a mut T { &mut *self._data } } -/**************************************************************************** - * Barrier - ****************************************************************************/ - /// A barrier enables multiple tasks to synchronize the beginning /// of some computation. /// @@ -452,10 +436,6 @@ impl Barrier { } } -/**************************************************************************** - * Tests - ****************************************************************************/ - #[cfg(test)] mod tests { use std::prelude::*; @@ -795,9 +775,6 @@ mod tests { } } - /************************************************************************ - * Barrier tests - ************************************************************************/ #[test] fn test_barrier() { let barrier = Arc::new(Barrier::new(10)); diff --git a/src/libsync/raw.rs b/src/libsync/raw.rs index 8ab21fe380f6c..112ace219dfe8 100644 --- a/src/libsync/raw.rs +++ b/src/libsync/raw.rs @@ -28,10 +28,6 @@ use collections::Vec; use mutex; use comm::{Receiver, Sender, channel}; -/**************************************************************************** - * Internals - ****************************************************************************/ - // Each waiting task receives on one of these. type WaitEnd = Receiver<()>; type SignalEnd = Sender<()>; @@ -349,10 +345,6 @@ struct SemCondGuard<'a> { cvar: Condvar<'a>, } -/**************************************************************************** - * Semaphores - ****************************************************************************/ - /// A counting, blocking, bounded-waiting semaphore. pub struct Semaphore { sem: Sem<()>, @@ -390,10 +382,6 @@ impl Semaphore { } } -/**************************************************************************** - * Mutexes - ****************************************************************************/ - /// A blocking, bounded-waiting, mutual exclusion lock with an associated /// FIFO condition variable. /// @@ -437,10 +425,6 @@ impl Mutex { } } -/**************************************************************************** - * Reader-writer locks - ****************************************************************************/ - // NB: Wikipedia - Readers-writers_problem#The_third_readers-writers_problem /// A blocking, no-starvation, reader-writer lock with an associated condvar. @@ -614,10 +598,6 @@ impl<'a> Drop for RWLockReadGuard<'a> { } } -/**************************************************************************** - * Tests - ****************************************************************************/ - #[cfg(test)] mod tests { pub use self::RWLockMode::*; @@ -631,9 +611,6 @@ mod tests { use std::result; use std::task; - /************************************************************************ - * Semaphore tests - ************************************************************************/ #[test] fn test_sem_acquire_release() { let s = Semaphore::new(1); @@ -641,16 +618,19 @@ mod tests { s.release(); s.acquire(); } + #[test] fn test_sem_basic() { let s = Semaphore::new(1); let _g = s.access(); } + #[test] #[should_fail] fn test_sem_basic2() { Semaphore::new(-1); } + #[test] fn test_sem_as_mutex() { let s = Arc::new(Semaphore::new(1)); @@ -662,6 +642,7 @@ mod tests { let _g = s.access(); for _ in range(0u, 5) { task::deschedule(); } } + #[test] fn test_sem_as_cvar() { /* Child waits and parent signals */ @@ -688,6 +669,7 @@ mod tests { s.acquire(); tx.send(()); } + #[test] fn test_sem_multi_resource() { // Parent and child both get in the critical section at the same @@ -705,6 +687,7 @@ mod tests { tx2.send(()); let _ = rx1.recv(); } + #[test] fn test_sem_runtime_friendly_blocking() { // Force the runtime to schedule two threads on the same sched_loop. @@ -724,9 +707,7 @@ mod tests { } rx.recv(); // wait for child to be done } - /************************************************************************ - * Mutex tests - ************************************************************************/ + #[test] fn test_mutex_lock() { // Unsafely achieve shared state, and do the textbook @@ -758,6 +739,7 @@ mod tests { } } } + #[test] fn test_mutex_cond_wait() { let m = Arc::new(Mutex::new()); @@ -817,14 +799,17 @@ mod tests { // wait until all children wake up for rx in rxs.iter_mut() { rx.recv(); } } + #[test] fn test_mutex_cond_broadcast() { test_mutex_cond_broadcast_helper(12); } + #[test] fn test_mutex_cond_broadcast_none() { test_mutex_cond_broadcast_helper(0); } + #[test] fn test_mutex_cond_no_waiter() { let m = Arc::new(Mutex::new()); @@ -835,6 +820,7 @@ mod tests { let lock = m2.lock(); assert!(!lock.cond.signal()); } + #[test] fn test_mutex_killed_simple() { use std::any::Any; @@ -851,6 +837,7 @@ mod tests { // child task must have finished by the time try returns drop(m.lock()); } + #[test] fn test_mutex_cond_signal_on_0() { // Tests that signal_on(0) is equivalent to signal(). @@ -863,6 +850,7 @@ mod tests { }); lock.cond.wait(); } + #[test] fn test_mutex_no_condvars() { let result = task::try(proc() { @@ -881,11 +869,10 @@ mod tests { }); assert!(result.is_err()); } - /************************************************************************ - * Reader/writer lock tests - ************************************************************************/ + #[cfg(test)] pub enum RWLockMode { Read, Write, Downgrade, DowngradeRead } + #[cfg(test)] fn lock_rwlock_in_mode(x: &Arc, mode: RWLockMode, blk: ||) { match mode { @@ -895,6 +882,7 @@ mod tests { DowngradeRead => { let _g = x.write().downgrade(); blk() } } } + #[cfg(test)] fn test_rwlock_exclusion(x: Arc, mode1: RWLockMode, @@ -931,6 +919,7 @@ mod tests { } } } + #[test] fn test_rwlock_readers_wont_modify_the_data() { test_rwlock_exclusion(Arc::new(RWLock::new()), Read, Write); @@ -940,6 +929,7 @@ mod tests { test_rwlock_exclusion(Arc::new(RWLock::new()), Write, DowngradeRead); test_rwlock_exclusion(Arc::new(RWLock::new()), DowngradeRead, Write); } + #[test] fn test_rwlock_writers_and_writers() { test_rwlock_exclusion(Arc::new(RWLock::new()), Write, Write); @@ -947,6 +937,7 @@ mod tests { test_rwlock_exclusion(Arc::new(RWLock::new()), Downgrade, Write); test_rwlock_exclusion(Arc::new(RWLock::new()), Downgrade, Downgrade); } + #[cfg(test)] fn test_rwlock_handshake(x: Arc, mode1: RWLockMode, @@ -979,6 +970,7 @@ mod tests { rx1.recv(); }) } + #[test] fn test_rwlock_readers_and_readers() { test_rwlock_handshake(Arc::new(RWLock::new()), Read, Read, false); @@ -988,6 +980,7 @@ mod tests { test_rwlock_handshake(Arc::new(RWLock::new()), Read, DowngradeRead, true); // Two downgrade_reads can never both end up reading at the same time. } + #[test] fn test_rwlock_downgrade_unlock() { // Tests that downgrade can unlock the lock in both modes @@ -998,12 +991,14 @@ mod tests { lock_rwlock_in_mode(&y, DowngradeRead, || { }); test_rwlock_exclusion(y, Write, Write); } + #[test] fn test_rwlock_read_recursive() { let x = RWLock::new(); let _g1 = x.read(); let _g2 = x.read(); } + #[test] fn test_rwlock_cond_wait() { // As test_mutex_cond_wait above. @@ -1037,6 +1032,7 @@ mod tests { rx.recv(); // Wait until child wakes up drop(x.read()); // Just for good measure } + #[cfg(test)] fn test_rwlock_cond_broadcast_helper(num_waiters: uint) { // Much like the mutex broadcast test. Downgrade-enabled. @@ -1070,11 +1066,13 @@ mod tests { // wait until all children wake up for rx in rxs.iter_mut() { let _ = rx.recv(); } } + #[test] fn test_rwlock_cond_broadcast() { test_rwlock_cond_broadcast_helper(0); test_rwlock_cond_broadcast_helper(12); } + #[cfg(test)] fn rwlock_kill_helper(mode1: RWLockMode, mode2: RWLockMode) { use std::any::Any; @@ -1092,22 +1090,27 @@ mod tests { // child task must have finished by the time try returns lock_rwlock_in_mode(&x, mode2, || { }) } + #[test] fn test_rwlock_reader_killed_writer() { rwlock_kill_helper(Read, Write); } + #[test] fn test_rwlock_writer_killed_reader() { rwlock_kill_helper(Write, Read); } + #[test] fn test_rwlock_reader_killed_reader() { rwlock_kill_helper(Read, Read); } + #[test] fn test_rwlock_writer_killed_writer() { rwlock_kill_helper(Write, Write); } + #[test] fn test_rwlock_kill_downgrader() { rwlock_kill_helper(Downgrade, Read); diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index b019b31de5f3f..bea7c394e7570 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -83,12 +83,10 @@ impl Sub for CharPos { } } -/** -Spans represent a region of code, used for error reporting. Positions in spans -are *absolute* positions from the beginning of the codemap, not positions -relative to FileMaps. Methods on the CodeMap can be used to relate spans back -to the original source. -*/ +/// Spans represent a region of code, used for error reporting. Positions in spans +/// are *absolute* positions from the beginning of the codemap, not positions +/// relative to FileMaps. Methods on the CodeMap can be used to relate spans back +/// to the original source. #[deriving(Clone, Show, Hash)] pub struct Span { pub lo: BytePos, diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index eaa3632cf499e..e703ac21f2642 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -17,16 +17,12 @@ use parse::token::*; use parse::token; use ptr::P; -/** -* -* Quasiquoting works via token trees. -* -* This is registered as a set of expression syntax extension called quote! -* that lifts its argument token-tree to an AST representing the -* construction of the same token tree, with token::SubstNt interpreted -* as antiquotes (splices). -* -*/ +//! Quasiquoting works via token trees. +//! +//! This is registered as a set of expression syntax extension called quote! +//! that lifts its argument token-tree to an AST representing the +//! construction of the same token tree, with token::SubstNt interpreted +//! as antiquotes (splices). pub mod rt { use ast; diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 3a3407aedba96..583ace977fe46 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -421,13 +421,11 @@ macro_rules! declare_special_idents_and_keywords {( )* } - /** - * All the valid words that have meaning in the Rust language. - * - * Rust keywords are either 'strict' or 'reserved'. Strict keywords may not - * appear as identifiers at all. Reserved keywords are not used anywhere in - * the language and may not appear as identifiers. - */ + /// All the valid words that have meaning in the Rust language. + /// + /// Rust keywords are either 'strict' or 'reserved'. Strict keywords may not + /// appear as identifiers at all. Reserved keywords are not used anywhere in + /// the language and may not appear as identifiers. pub mod keywords { pub use self::Keyword::*; use ast; diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs index cfb4c3bc40322..62a49c5d90270 100644 --- a/src/libterm/terminfo/parm.rs +++ b/src/libterm/terminfo/parm.rs @@ -80,17 +80,15 @@ impl Variables { } } -/** - Expand a parameterized capability - - # Arguments - * `cap` - string to expand - * `params` - vector of params for %p1 etc - * `vars` - Variables struct for %Pa etc - - To be compatible with ncurses, `vars` should be the same between calls to `expand` for - multiple capabilities for the same terminal. - */ +/// Expand a parameterized capability +/// +/// # Arguments +/// * `cap` - string to expand +/// * `params` - vector of params for %p1 etc +/// * `vars` - Variables struct for %Pa etc +/// +/// To be compatible with ncurses, `vars` should be the same between calls to `expand` for +/// multiple capabilities for the same terminal. pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) -> Result , String> { let mut state = Nothing; diff --git a/src/libtime/lib.rs b/src/libtime/lib.rs index 062035c23f906..135c8a7280880 100644 --- a/src/libtime/lib.rs +++ b/src/libtime/lib.rs @@ -123,10 +123,8 @@ impl Sub for Timespec { } } -/** - * Returns the current time as a `timespec` containing the seconds and - * nanoseconds since 1970-01-01T00:00:00Z. - */ +/// Returns the current time as a `timespec` containing the seconds and +/// nanoseconds since 1970-01-01T00:00:00Z. pub fn get_time() -> Timespec { unsafe { let (sec, nsec) = os_get_time(); @@ -171,10 +169,8 @@ pub fn get_time() -> Timespec { } -/** - * Returns the current value of a high-resolution performance counter - * in nanoseconds since an unspecified epoch. - */ +/// Returns the current value of a high-resolution performance counter +/// in nanoseconds since an unspecified epoch. pub fn precise_time_ns() -> u64 { return os_precise_time_ns(); @@ -218,10 +214,8 @@ pub fn precise_time_ns() -> u64 { } -/** - * Returns the current value of a high-resolution performance counter - * in seconds since an unspecified epoch. - */ +/// Returns the current value of a high-resolution performance counter +/// in seconds since an unspecified epoch. pub fn precise_time_s() -> f64 { return (precise_time_ns() as f64) / 1000000000.; } @@ -346,12 +340,10 @@ impl Tm { at_utc(self.to_timespec()) } - /** - * Returns a TmFmt that outputs according to the `asctime` format in ISO - * C, in the local timezone. - * - * Example: "Thu Jan 1 00:00:00 1970" - */ + /// Returns a TmFmt that outputs according to the `asctime` format in ISO + /// C, in the local timezone. + /// + /// Example: "Thu Jan 1 00:00:00 1970" pub fn ctime(&self) -> TmFmt { TmFmt { tm: self, @@ -359,12 +351,10 @@ impl Tm { } } - /** - * Returns a TmFmt that outputs according to the `asctime` format in ISO - * C. - * - * Example: "Thu Jan 1 00:00:00 1970" - */ + /// Returns a TmFmt that outputs according to the `asctime` format in ISO + /// C. + /// + /// Example: "Thu Jan 1 00:00:00 1970" pub fn asctime(&self) -> TmFmt { TmFmt { tm: self, @@ -380,12 +370,10 @@ impl Tm { }) } - /** - * Returns a TmFmt that outputs according to RFC 822. - * - * local: "Thu, 22 Mar 2012 07:53:18 PST" - * utc: "Thu, 22 Mar 2012 14:53:18 GMT" - */ + /// Returns a TmFmt that outputs according to RFC 822. + /// + /// local: "Thu, 22 Mar 2012 07:53:18 PST" + /// utc: "Thu, 22 Mar 2012 14:53:18 GMT" pub fn rfc822(&self) -> TmFmt { if self.tm_gmtoff == 0_i32 { TmFmt { @@ -400,12 +388,10 @@ impl Tm { } } - /** - * Returns a TmFmt that outputs according to RFC 822 with Zulu time. - * - * local: "Thu, 22 Mar 2012 07:53:18 -0700" - * utc: "Thu, 22 Mar 2012 14:53:18 -0000" - */ + /// Returns a TmFmt that outputs according to RFC 822 with Zulu time. + /// + /// local: "Thu, 22 Mar 2012 07:53:18 -0700" + /// utc: "Thu, 22 Mar 2012 14:53:18 -0000" pub fn rfc822z(&self) -> TmFmt { TmFmt { tm: self, @@ -413,13 +399,11 @@ impl Tm { } } - /** - * Returns a TmFmt that outputs according to RFC 3339. RFC 3339 is - * compatible with ISO 8601. - * - * local: "2012-02-22T07:53:18-07:00" - * utc: "2012-02-22T14:53:18Z" - */ + /// Returns a TmFmt that outputs according to RFC 3339. RFC 3339 is + /// compatible with ISO 8601. + /// + /// local: "2012-02-22T07:53:18-07:00" + /// utc: "2012-02-22T14:53:18Z" pub fn rfc3339<'a>(&'a self) -> TmFmt { TmFmt { tm: self,