提交 763d846d 编写于 作者: B Brendan Zabarauskas 提交者: Daniel Micay

Impl Not for bool

上级 f2bd4416
......@@ -19,6 +19,8 @@
Implementations of the following traits:
* `FromStr`
* `ToStr`
* `Not`
* `Ord`
* `TotalOrd`
* `Eq`
......@@ -36,6 +38,8 @@
#[cfg(not(test))]
use cmp::{Eq, Ord, TotalOrd, Ordering};
#[cfg(not(test))]
use ops::Not;
use option::{None, Option, Some};
use from_str::FromStr;
use to_str::ToStr;
......@@ -254,6 +258,27 @@ pub fn all_values(blk: &fn(v: bool)) {
#[inline]
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))]
impl Ord for bool {
#[inline]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册