Skip to content

Commit

Permalink
make rustdocs more terse for bool.rs where it is obvious to programme…
Browse files Browse the repository at this point in the history
…rs as per feedback from graydon
  • Loading branch information
rtanglao authored and brson committed Jan 12, 2012
1 parent 350e87e commit 81c3028
Showing 1 changed file with 13 additions and 45 deletions.
58 changes: 13 additions & 45 deletions src/libcore/bool.rs
Expand Up @@ -11,78 +11,52 @@ export from_str, to_str, all_values, to_bit;
type t = bool;

#[doc(
brief = "Negation/Inverse",
args(v = "Value to Negate/Invert"),
return = "Negated/Inverted Value"
brief = "Negation/Inverse"
)]
pure fn not(v: t) -> t { !v }

#[doc(
brief = "Conjunction",
args(a = "value `a`",
b = "value `b`"),
return = "`a` AND `b`"
brief = "Conjunction"
)]
pure fn and(a: t, b: t) -> t { a && b }

#[doc(
brief = "Disjunction",
args(a = "value `a`",
b = "value `b`"),
return = "`a` OR `b`"
brief = "Disjunction"
)]
pure fn or(a: t, b: t) -> t { a || b }

#[doc(
brief = "Exclusive or, i.e. `or(and(a, not(b)), and(not(a), b))`",
args(a = "value `a`",
b = "value `b`"),
return = "`a` XOR `b`"
brief = "Exclusive or, i.e. `or(and(a, not(b)), and(not(a), b))`"
)]
pure fn xor(a: t, b: t) -> t { (a && !b) || (!a && b) }

#[doc(
brief = "Implication in the logic, i.e. from `a` follows `b`",
args(a = "value `a`",
b = "value `b`"),
return = "`a` IMPLIES `b`"
brief = "Implication in the logic, i.e. from `a` follows `b`"
)]
pure fn implies(a: t, b: t) -> t { !a || b }

#[doc(
brief = "true if truth values `a` and `b` are indistinguishable in the logic",
args(a = "value `a`",
b = "value `b`"),
return = "`a` == `b`"
brief = "true if truth values `a` and `b` are indistinguishable in the logic"
)]
pure fn eq(a: t, b: t) -> bool { a == b }

#[doc(
brief = "true if truth values `a` and `b` are distinguishable in the logic",
args(a = "value `a`",
b = "value `b`"),
return = "`a` != `b`"
brief = "true if truth values `a` and `b` are distinguishable in the logic"
)]
pure fn ne(a: t, b: t) -> bool { a != b }

#[doc(
brief = "true if `v` represents truth in the logic",
args(v = "value `v`"),
return = "bool(`v`)"
brief = "true if `v` represents truth in the logic"
)]
pure fn is_true(v: t) -> bool { v }

#[doc(
brief = "true if `v` represents falsehood in the logic",
args(v = "value `v`"),
return = "bool(!`v`)"
brief = "true if `v` represents falsehood in the logic"
)]
pure fn is_false(v: t) -> bool { !v }

#[doc(
brief = "Parse logic value from `s`",
args(v = "string value `s`"),
return = "true if `s` equals \"true\", else false"
brief = "Parse logic value from `s`"
)]
pure fn from_str(s: str) -> t {
alt s {
Expand All @@ -92,26 +66,20 @@ pure fn from_str(s: str) -> t {
}

#[doc(
brief = "Convert `v` into a string",
args(v = "truth value `v`"),
return = "\"true\" if value `v` is true, else \"false\""
brief = "Convert `v` into a string"
)]
pure fn to_str(v: t) -> str { if v { "true" } else { "false" } }

#[doc(
brief = "Iterates over all truth values by passing them to `blk` in an unspecified order",
args(v = "block value `v`"),
return = "Undefined return value"
brief = "Iterates over all truth values by passing them to `blk` in an unspecified order"
)]
fn all_values(blk: block(v: t)) {
blk(true);
blk(false);
}

#[doc(
brief = "converts truth value to an 8 bit byte",
args(v = "value `v`"),
return = "returns byte with value 1 if `v` has truth value of true, else 0"
brief = "converts truth value to an 8 bit byte"
)]
pure fn to_bit(v: t) -> u8 { if v { 1u8 } else { 0u8 } }

Expand Down

0 comments on commit 81c3028

Please sign in to comment.