Skip to content

Commit ac1d8cd

Browse files
committed
---
yaml --- r: 114677 b: refs/heads/auto c: 6636215 h: refs/heads/master i: 114675: b90292e v: v3
1 parent 1805348 commit ac1d8cd

File tree

5 files changed

+42
-37
lines changed

5 files changed

+42
-37
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 92095d125ab4353a7bae002b893c2bd1bd06e379
16+
refs/heads/auto: 6636215a44b27d1806a2ac646bde1d4ecaa801c4
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libstd/bool.rs renamed to branches/auto/src/libcore/bool.rs

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
//!
1515
//! Implementations of the following traits:
1616
//!
17-
//! * `FromStr`
1817
//! * `Not`
1918
//! * `Ord`
2019
//! * `TotalOrd`
@@ -24,11 +23,9 @@
2423
//!
2524
//! A `to_bit` conversion function.
2625
27-
use from_str::FromStr;
2826
use num::{Int, one, zero};
29-
use option::{None, Option, Some};
3027

31-
#[cfg(not(test))] use cmp::{Eq, Ord, TotalOrd, Ordering};
28+
#[cfg(not(test))] use cmp::{Eq, Ord, TotalOrd, Ordering, TotalEq};
3229
#[cfg(not(test))] use ops::{Not, BitAnd, BitOr, BitXor};
3330
#[cfg(not(test))] use default::Default;
3431

@@ -55,28 +52,6 @@ pub fn to_bit<N: Int>(p: bool) -> N {
5552
// Trait impls on `bool`
5653
/////////////////////////////////////////////////////////////////////////////
5754

58-
impl FromStr for bool {
59-
/// Parse a `bool` from a string.
60-
///
61-
/// Yields an `Option<bool>`, because `s` may or may not actually be parseable.
62-
///
63-
/// # Examples
64-
///
65-
/// ```rust
66-
/// assert_eq!(from_str::<bool>("true"), Some(true));
67-
/// assert_eq!(from_str::<bool>("false"), Some(false));
68-
/// assert_eq!(from_str::<bool>("not even a boolean"), None);
69-
/// ```
70-
#[inline]
71-
fn from_str(s: &str) -> Option<bool> {
72-
match s {
73-
"true" => Some(true),
74-
"false" => Some(false),
75-
_ => None,
76-
}
77-
}
78-
}
79-
8055
#[cfg(not(test))]
8156
impl Not<bool> for bool {
8257
/// The logical complement of a boolean value.
@@ -190,6 +165,9 @@ impl Eq for bool {
190165
fn eq(&self, other: &bool) -> bool { (*self) == (*other) }
191166
}
192167

168+
#[cfg(not(test))]
169+
impl TotalEq for bool {}
170+
193171
#[cfg(not(test))]
194172
impl Default for bool {
195173
fn default() -> bool { false }
@@ -260,13 +238,6 @@ mod tests {
260238
assert_eq!(!false, true);
261239
}
262240

263-
#[test]
264-
fn test_from_str() {
265-
assert_eq!(from_str::<bool>("true"), Some(true));
266-
assert_eq!(from_str::<bool>("false"), Some(false));
267-
assert_eq!(from_str::<bool>("not even a boolean"), None);
268-
}
269-
270241
#[test]
271242
fn test_to_str() {
272243
assert_eq!(false.to_str(), "false".to_owned());

branches/auto/src/libcore/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub mod container;
4141

4242
mod unit;
4343
pub mod any;
44+
pub mod bool;
4445
pub mod finally;
4546
pub mod raw;
4647
pub mod char;

branches/auto/src/libstd/from_str.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! The `FromStr` trait for types that can be created from strings
1212
13-
use option::Option;
13+
use option::{Option, Some, None};
1414

1515
/// A trait to abstract the idea of creating a new instance of a type from a
1616
/// string.
@@ -24,3 +24,37 @@ pub trait FromStr {
2424
pub fn from_str<A: FromStr>(s: &str) -> Option<A> {
2525
FromStr::from_str(s)
2626
}
27+
28+
impl FromStr for bool {
29+
/// Parse a `bool` from a string.
30+
///
31+
/// Yields an `Option<bool>`, because `s` may or may not actually be parseable.
32+
///
33+
/// # Examples
34+
///
35+
/// ```rust
36+
/// assert_eq!(from_str::<bool>("true"), Some(true));
37+
/// assert_eq!(from_str::<bool>("false"), Some(false));
38+
/// assert_eq!(from_str::<bool>("not even a boolean"), None);
39+
/// ```
40+
#[inline]
41+
fn from_str(s: &str) -> Option<bool> {
42+
match s {
43+
"true" => Some(true),
44+
"false" => Some(false),
45+
_ => None,
46+
}
47+
}
48+
}
49+
50+
#[cfg(test)]
51+
mod test {
52+
use prelude::*;
53+
54+
#[test]
55+
fn test_bool_from_str() {
56+
assert_eq!(from_str::<bool>("true"), Some(true));
57+
assert_eq!(from_str::<bool>("false"), Some(false));
58+
assert_eq!(from_str::<bool>("not even a boolean"), None);
59+
}
60+
}

branches/auto/src/libstd/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ extern crate core;
138138
#[cfg(not(test))] pub use ty = core::ty;
139139

140140
pub use core::any;
141+
pub use core::bool;
141142
pub use core::cast;
142143
pub use core::char;
143144
pub use core::clone;
@@ -192,8 +193,6 @@ pub mod prelude;
192193
#[path = "num/f32.rs"] pub mod f32;
193194
#[path = "num/f64.rs"] pub mod f64;
194195

195-
pub mod bool;
196-
197196
pub mod slice;
198197
pub mod vec;
199198
pub mod str;

0 commit comments

Comments
 (0)