Skip to content

Commit c80f4e1

Browse files
committed
Impl Not for bool
1 parent d243e00 commit c80f4e1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/libstd/bool.rs

+25
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ A quick summary:
1919
Implementations of the following traits:
2020
2121
* `FromStr`
22+
* `ToStr`
23+
* `Not`
2224
* `Ord`
2325
* `TotalOrd`
2426
* `Eq`
@@ -36,6 +38,8 @@ Finally, some inquries into the nature of truth: `is_true` and `is_false`.
3638

3739
#[cfg(not(test))]
3840
use cmp::{Eq, Ord, TotalOrd, Ordering};
41+
#[cfg(not(test))]
42+
use ops::Not;
3943
use option::{None, Option, Some};
4044
use from_str::FromStr;
4145
use to_str::ToStr;
@@ -254,6 +258,27 @@ pub fn all_values(blk: &fn(v: bool)) {
254258
#[inline]
255259
pub fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
256260

261+
/**
262+
* The logical complement of a boolean value.
263+
*
264+
* # Examples
265+
*
266+
* ~~~rust
267+
* rusti> !true
268+
* false
269+
* ~~~
270+
*
271+
* ~~~rust
272+
* rusti> !false
273+
* true
274+
* ~~~
275+
*/
276+
#[cfg(not(test))]
277+
impl Not<bool> for bool {
278+
#[inline]
279+
fn not(&self) -> bool { !*self }
280+
}
281+
257282
#[cfg(not(test))]
258283
impl Ord for bool {
259284
#[inline]

0 commit comments

Comments
 (0)