Skip to content

Commit 1179a99

Browse files
committed
---
yaml --- r: 24168 b: refs/heads/master c: e956ede h: refs/heads/master v: v3
1 parent 869e860 commit 1179a99

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
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 8b13912a839a5e0336fa285d9b62c1337e17b165
2+
refs/heads/master: e956edeb55f3f2875fd2fe00cb21bd48f29c1842
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/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)