Impl Not for bool
This commit is contained in:
parent
d243e0047d
commit
c80f4e1c11
1 changed files with 25 additions and 0 deletions
|
|
@ -19,6 +19,8 @@ A quick summary:
|
||||||
Implementations of the following traits:
|
Implementations of the following traits:
|
||||||
|
|
||||||
* `FromStr`
|
* `FromStr`
|
||||||
|
* `ToStr`
|
||||||
|
* `Not`
|
||||||
* `Ord`
|
* `Ord`
|
||||||
* `TotalOrd`
|
* `TotalOrd`
|
||||||
* `Eq`
|
* `Eq`
|
||||||
|
|
@ -36,6 +38,8 @@ Finally, some inquries into the nature of truth: `is_true` and `is_false`.
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use cmp::{Eq, Ord, TotalOrd, Ordering};
|
use cmp::{Eq, Ord, TotalOrd, Ordering};
|
||||||
|
#[cfg(not(test))]
|
||||||
|
use ops::Not;
|
||||||
use option::{None, Option, Some};
|
use option::{None, Option, Some};
|
||||||
use from_str::FromStr;
|
use from_str::FromStr;
|
||||||
use to_str::ToStr;
|
use to_str::ToStr;
|
||||||
|
|
@ -254,6 +258,27 @@ pub fn all_values(blk: &fn(v: bool)) {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
|
pub fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The logical complement of a boolean value.
|
||||||
|
*
|
||||||
|
* # Examples
|
||||||
|
*
|
||||||
|
* ~~~rust
|
||||||
|
* rusti> !true
|
||||||
|
* false
|
||||||
|
* ~~~
|
||||||
|
*
|
||||||
|
* ~~~rust
|
||||||
|
* rusti> !false
|
||||||
|
* true
|
||||||
|
* ~~~
|
||||||
|
*/
|
||||||
|
#[cfg(not(test))]
|
||||||
|
impl Not<bool> for bool {
|
||||||
|
#[inline]
|
||||||
|
fn not(&self) -> bool { !*self }
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
impl Ord for bool {
|
impl Ord for bool {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue