Skip to content

Commit 59e88a5

Browse files
committed
---
yaml --- r: 30768 b: refs/heads/incoming c: e956ede h: refs/heads/master v: v3
1 parent 5e9c872 commit 59e88a5

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 8b13912a839a5e0336fa285d9b62c1337e17b165
9+
refs/heads/incoming: e956edeb55f3f2875fd2fe00cb21bd48f29c1842
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/bool.rs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,39 @@
88
99
use cmp::Eq;
1010

11-
export not, and, or, xor, implies;
12-
export eq, ne, is_true, is_false;
13-
export from_str, to_str, all_values, to_bit;
14-
1511
/// Negation / inverse
16-
pure fn not(v: bool) -> bool { !v }
12+
pub pure fn not(v: bool) -> bool { !v }
1713

1814
/// Conjunction
19-
pure fn and(a: bool, b: bool) -> bool { a && b }
15+
pub pure fn and(a: bool, b: bool) -> bool { a && b }
2016

2117
/// Disjunction
22-
pure fn or(a: bool, b: bool) -> bool { a || b }
18+
pub pure fn or(a: bool, b: bool) -> bool { a || b }
2319

2420
/**
2521
* Exclusive or
2622
*
2723
* Identical to `or(and(a, not(b)), and(not(a), b))`
2824
*/
29-
pure fn xor(a: bool, b: bool) -> bool { (a && !b) || (!a && b) }
25+
pub pure fn xor(a: bool, b: bool) -> bool { (a && !b) || (!a && b) }
3026

3127
/// Implication in the logic, i.e. from `a` follows `b`
32-
pure fn implies(a: bool, b: bool) -> bool { !a || b }
28+
pub pure fn implies(a: bool, b: bool) -> bool { !a || b }
3329

3430
/// true if truth values `a` and `b` are indistinguishable in the logic
35-
pure fn eq(a: bool, b: bool) -> bool { a == b }
31+
pub pure fn eq(a: bool, b: bool) -> bool { a == b }
3632

3733
/// true if truth values `a` and `b` are distinguishable in the logic
38-
pure fn ne(a: bool, b: bool) -> bool { a != b }
34+
pub pure fn ne(a: bool, b: bool) -> bool { a != b }
3935

4036
/// true if `v` represents truth in the logic
41-
pure fn is_true(v: bool) -> bool { v }
37+
pub pure fn is_true(v: bool) -> bool { v }
4238

4339
/// true if `v` represents falsehood in the logic
44-
pure fn is_false(v: bool) -> bool { !v }
40+
pub pure fn is_false(v: bool) -> bool { !v }
4541

4642
/// Parse logic value from `s`
47-
pure fn from_str(s: &str) -> Option<bool> {
43+
pub pure fn from_str(s: &str) -> Option<bool> {
4844
if s == "true" {
4945
Some(true)
5046
} else if s == "false" {
@@ -55,40 +51,40 @@ pure fn from_str(s: &str) -> Option<bool> {
5551
}
5652

5753
/// Convert `v` into a string
58-
pure fn to_str(v: bool) -> ~str { if v { ~"true" } else { ~"false" } }
54+
pub pure fn to_str(v: bool) -> ~str { if v { ~"true" } else { ~"false" } }
5955

6056
/**
6157
* Iterates over all truth values by passing them to `blk` in an unspecified
6258
* order
6359
*/
64-
fn all_values(blk: fn(v: bool)) {
60+
pub fn all_values(blk: fn(v: bool)) {
6561
blk(true);
6662
blk(false);
6763
}
6864

6965
/// converts truth value to an 8 bit byte
70-
pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
66+
pub pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
7167

7268
impl bool : cmp::Eq {
7369
pure fn eq(other: &bool) -> bool { self == (*other) }
7470
pure fn ne(other: &bool) -> bool { self != (*other) }
7571
}
7672

7773
#[test]
78-
fn test_bool_from_str() {
74+
pub fn test_bool_from_str() {
7975
do all_values |v| {
8076
assert Some(v) == from_str(bool::to_str(v))
8177
}
8278
}
8379

8480
#[test]
85-
fn test_bool_to_str() {
81+
pub fn test_bool_to_str() {
8682
assert to_str(false) == ~"false";
8783
assert to_str(true) == ~"true";
8884
}
8985

9086
#[test]
91-
fn test_bool_to_bit() {
87+
pub fn test_bool_to_bit() {
9288
do all_values |v| {
9389
assert to_bit(v) == if is_true(v) { 1u8 } else { 0u8 };
9490
}

0 commit comments

Comments
 (0)