Skip to content

Commit 258320d

Browse files
rtanglaobrson
authored andcommitted
---
yaml --- r: 7191 b: refs/heads/master c: 350e87e h: refs/heads/master i: 7189: c3a807b 7187: e686160 7183: 9fd9479 v: v3
1 parent 021c4bd commit 258320d

File tree

2 files changed

+74
-84
lines changed

2 files changed

+74
-84
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 2c70b2fb7ee33c663cc96c420daaa74b951b3af9
2+
refs/heads/master: 350e87eaae66811cebf8ab6535c69984473d1b08

trunk/src/libcore/bool.rs

Lines changed: 73 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,118 @@
11
// -*- rust -*-
22

3-
/*
4-
Module: bool
5-
6-
Classic Boolean logic reified as ADT
7-
*/
3+
#[doc = "Classic Boolean logic reified as ADT"];
84

95
export t;
106
export not, and, or, xor, implies;
117
export eq, ne, is_true, is_false;
128
export from_str, to_str, all_values, to_bit;
139

14-
/*
15-
Type: t
16-
17-
The type of boolean logic values
18-
*/
10+
#[doc = "The type of boolean logic values"]
1911
type t = bool;
2012

21-
/* Function: not
22-
23-
Negation/Inverse
24-
*/
13+
#[doc(
14+
brief = "Negation/Inverse",
15+
args(v = "Value to Negate/Invert"),
16+
return = "Negated/Inverted Value"
17+
)]
2518
pure fn not(v: t) -> t { !v }
2619

27-
/* Function: and
28-
29-
Conjunction
30-
*/
20+
#[doc(
21+
brief = "Conjunction",
22+
args(a = "value `a`",
23+
b = "value `b`"),
24+
return = "`a` AND `b`"
25+
)]
3126
pure fn and(a: t, b: t) -> t { a && b }
3227

33-
/* Function: or
34-
35-
Disjunction
36-
*/
28+
#[doc(
29+
brief = "Disjunction",
30+
args(a = "value `a`",
31+
b = "value `b`"),
32+
return = "`a` OR `b`"
33+
)]
3734
pure fn or(a: t, b: t) -> t { a || b }
3835

39-
/*
40-
Function: xor
41-
42-
Exclusive or, i.e. `or(and(a, not(b)), and(not(a), b))`
43-
*/
36+
#[doc(
37+
brief = "Exclusive or, i.e. `or(and(a, not(b)), and(not(a), b))`",
38+
args(a = "value `a`",
39+
b = "value `b`"),
40+
return = "`a` XOR `b`"
41+
)]
4442
pure fn xor(a: t, b: t) -> t { (a && !b) || (!a && b) }
4543

46-
/*
47-
Function: implies
48-
49-
Implication in the logic, i.e. from `a` follows `b`
50-
*/
44+
#[doc(
45+
brief = "Implication in the logic, i.e. from `a` follows `b`",
46+
args(a = "value `a`",
47+
b = "value `b`"),
48+
return = "`a` IMPLIES `b`"
49+
)]
5150
pure fn implies(a: t, b: t) -> t { !a || b }
5251

53-
/*
54-
Predicate: eq
55-
56-
Returns:
57-
58-
true if truth values `a` and `b` are indistinguishable in the logic
59-
*/
52+
#[doc(
53+
brief = "true if truth values `a` and `b` are indistinguishable in the logic",
54+
args(a = "value `a`",
55+
b = "value `b`"),
56+
return = "`a` == `b`"
57+
)]
6058
pure fn eq(a: t, b: t) -> bool { a == b }
6159

62-
/*
63-
Predicate: ne
64-
65-
Returns:
66-
67-
true if truth values `a` and `b` are distinguishable in the logic
68-
*/
60+
#[doc(
61+
brief = "true if truth values `a` and `b` are distinguishable in the logic",
62+
args(a = "value `a`",
63+
b = "value `b`"),
64+
return = "`a` != `b`"
65+
)]
6966
pure fn ne(a: t, b: t) -> bool { a != b }
7067

71-
/*
72-
Predicate: is_true
73-
74-
Returns:
75-
76-
true if `v` represents truth in the logic
77-
*/
68+
#[doc(
69+
brief = "true if `v` represents truth in the logic",
70+
args(v = "value `v`"),
71+
return = "bool(`v`)"
72+
)]
7873
pure fn is_true(v: t) -> bool { v }
7974

80-
/*
81-
Predicate: is_false
82-
83-
Returns:
84-
85-
true if `v` represents falsehood in the logic
86-
*/
75+
#[doc(
76+
brief = "true if `v` represents falsehood in the logic",
77+
args(v = "value `v`"),
78+
return = "bool(!`v`)"
79+
)]
8780
pure fn is_false(v: t) -> bool { !v }
8881

89-
/*
90-
Function: from_str
91-
92-
Parse logic value from `s`
93-
*/
82+
#[doc(
83+
brief = "Parse logic value from `s`",
84+
args(v = "string value `s`"),
85+
return = "true if `s` equals \"true\", else false"
86+
)]
9487
pure fn from_str(s: str) -> t {
9588
alt s {
9689
"true" { true }
9790
"false" { false }
9891
}
9992
}
10093

101-
/*
102-
Function: to_str
103-
104-
Convert `v` into a string
105-
*/
94+
#[doc(
95+
brief = "Convert `v` into a string",
96+
args(v = "truth value `v`"),
97+
return = "\"true\" if value `v` is true, else \"false\""
98+
)]
10699
pure fn to_str(v: t) -> str { if v { "true" } else { "false" } }
107100

108-
/*
109-
Function: all_values
110-
111-
Iterates over all truth values by passing them to `blk`
112-
in an unspecified order
113-
*/
101+
#[doc(
102+
brief = "Iterates over all truth values by passing them to `blk` in an unspecified order",
103+
args(v = "block value `v`"),
104+
return = "Undefined return value"
105+
)]
114106
fn all_values(blk: block(v: t)) {
115107
blk(true);
116108
blk(false);
117109
}
118110

119-
/*
120-
Function: to_bit
121-
122-
Returns:
123-
124-
An u8 whose first bit is set if `if_true(v)` holds
125-
*/
111+
#[doc(
112+
brief = "converts truth value to an 8 bit byte",
113+
args(v = "value `v`"),
114+
return = "returns byte with value 1 if `v` has truth value of true, else 0"
115+
)]
126116
pure fn to_bit(v: t) -> u8 { if v { 1u8 } else { 0u8 } }
127117

128118
// Local Variables:

0 commit comments

Comments
 (0)