Skip to content

Commit 29b2d0f

Browse files
committed
---
yaml --- r: 73626 b: refs/heads/dist-snap c: e516d23 h: refs/heads/master v: v3
1 parent 5d8b5dc commit 29b2d0f

File tree

4 files changed

+40
-51
lines changed

4 files changed

+40
-51
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 55c23bc55706d71e2168c0eef42f59f20e06b75f
10+
refs/heads/dist-snap: e516d2333fa38ce29f1e6e119beb4d5711cf8fd5
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libstd/bool.rs

Lines changed: 38 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Finally, some inquries into the nature of truth: `is_true` and `is_false`.
3838
use cmp::{Eq, Ord, TotalOrd, Ordering};
3939
use option::{None, Option, Some};
4040
use from_str::FromStr;
41+
use to_str::ToStr;
4142

4243
/**
4344
* Negation of a boolean value.
@@ -129,44 +130,6 @@ pub fn xor(a: bool, b: bool) -> bool { (a && !b) || (!a && b) }
129130
*/
130131
pub fn implies(a: bool, b: bool) -> bool { !a || b }
131132

132-
/**
133-
* Equality between two boolean values.
134-
*
135-
* Two booleans are equal if they have the same value.
136-
*
137-
* # Examples
138-
*
139-
* ~~~ {.rust}
140-
* rusti> std::bool::eq(false, true)
141-
* false
142-
* ~~~
143-
*
144-
* ~~~ {.rust}
145-
* rusti> std::bool::eq(false, false)
146-
* true
147-
* ~~~
148-
*/
149-
pub fn eq(a: bool, b: bool) -> bool { a == b }
150-
151-
/**
152-
* Non-equality between two boolean values.
153-
*
154-
* Two booleans are not equal if they have different values.
155-
*
156-
* # Examples
157-
*
158-
* ~~~ {.rust}
159-
* rusti> std::bool::ne(false, true)
160-
* true
161-
* ~~~
162-
*
163-
* ~~~ {.rust}
164-
* rusti> std::bool::ne(false, false)
165-
* false
166-
* ~~~
167-
*/
168-
pub fn ne(a: bool, b: bool) -> bool { a != b }
169-
170133
/**
171134
* Is a given boolean value true?
172135
*
@@ -239,16 +202,21 @@ impl FromStr for bool {
239202
* # Examples
240203
*
241204
* ~~~ {.rust}
242-
* rusti> std::bool::to_str(true)
205+
* rusti> true.to_str()
243206
* "true"
244207
* ~~~
245208
*
246209
* ~~~ {.rust}
247-
* rusti> std::bool::to_str(false)
210+
* rusti> false.to_str()
248211
* "false"
249212
* ~~~
250213
*/
251-
pub fn to_str(v: bool) -> ~str { if v { ~"true" } else { ~"false" } }
214+
impl ToStr for bool {
215+
#[inline(always)]
216+
fn to_str(&self) -> ~str {
217+
if *self { ~"true" } else { ~"false" }
218+
}
219+
}
252220

253221
/**
254222
* Iterates over all truth values, passing them to the given block.
@@ -258,7 +226,7 @@ pub fn to_str(v: bool) -> ~str { if v { ~"true" } else { ~"false" } }
258226
* # Examples
259227
* ~~~
260228
* do std::bool::all_values |x: bool| {
261-
* println(std::bool::to_str(x));
229+
* println(x.to_str())
262230
* }
263231
* ~~~
264232
*/
@@ -303,6 +271,31 @@ impl TotalOrd for bool {
303271
fn cmp(&self, other: &bool) -> Ordering { to_bit(*self).cmp(&to_bit(*other)) }
304272
}
305273

274+
/**
275+
* Equality between two boolean values.
276+
*
277+
* Two booleans are equal if they have the same value.
278+
*
279+
* ~~~ {.rust}
280+
* rusti> false.eq(&true)
281+
* false
282+
* ~~~
283+
*
284+
* ~~~ {.rust}
285+
* rusti> false == false
286+
* true
287+
* ~~~
288+
*
289+
* ~~~ {.rust}
290+
* rusti> false != true
291+
* true
292+
* ~~~
293+
*
294+
* ~~~ {.rust}
295+
* rusti> false.ne(&false)
296+
* false
297+
* ~~~
298+
*/
306299
#[cfg(not(test))]
307300
impl Eq for bool {
308301
#[inline(always)]
@@ -319,14 +312,14 @@ mod tests {
319312
#[test]
320313
fn test_bool_from_str() {
321314
do all_values |v| {
322-
assert!(Some(v) == FromStr::from_str(to_str(v)))
315+
assert!(Some(v) == FromStr::from_str(v.to_str()))
323316
}
324317
}
325318

326319
#[test]
327320
fn test_bool_to_str() {
328-
assert_eq!(to_str(false), ~"false");
329-
assert_eq!(to_str(true), ~"true");
321+
assert_eq!(false.to_str(), ~"false");
322+
assert_eq!(true.to_str(), ~"true");
330323
}
331324

332325
#[test]

branches/dist-snap/src/libstd/to_str.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ pub trait ToStrConsume {
3434
fn to_str_consume(self) -> ~str;
3535
}
3636

37-
impl ToStr for bool {
38-
#[inline(always)]
39-
fn to_str(&self) -> ~str { ::bool::to_str(*self) }
40-
}
4137
impl ToStr for () {
4238
#[inline(always)]
4339
fn to_str(&self) -> ~str { ~"()" }

branches/dist-snap/src/test/run-pass/reflect-visit-data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ impl TyVisitor for my_visitor {
517517
fn visit_nil(&self) -> bool { true }
518518
fn visit_bool(&self) -> bool {
519519
do self.get::<bool>() |b| {
520-
self.vals.push(bool::to_str(b));
520+
self.vals.push(b.to_str());
521521
};
522522
true
523523
}

0 commit comments

Comments
 (0)