diff options
| author | Andrew Paseltiner <apaseltiner@gmail.com> | 2013-01-11 12:16:58 -0500 |
|---|---|---|
| committer | Andrew Paseltiner <apaseltiner@gmail.com> | 2013-01-11 14:31:44 -0500 |
| commit | 0de7aa55062485835bc45b962f306dddf42f372d (patch) | |
| tree | 08f579044cdf177b10a65d9057c824441dc58a13 /src/libcore | |
| parent | a82c8b3da2ce3d1ea288f58d20c07984ebaf930c (diff) | |
| download | rust-0de7aa55062485835bc45b962f306dddf42f372d.tar.gz rust-0de7aa55062485835bc45b962f306dddf42f372d.zip | |
allow logical negation operator (!) to be overloaded
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/core.rc | 2 | ||||
| -rw-r--r-- | src/libcore/ops.rs | 6 | ||||
| -rw-r--r-- | src/libcore/prelude.rs | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/src/libcore/core.rc b/src/libcore/core.rc index f8658b8e46e..81b9077fb3e 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -172,7 +172,7 @@ pub mod util; pub use kinds::{Const, Copy, Owned, Durable}; pub use ops::{Drop}; -pub use ops::{Add, Sub, Mul, Div, Modulo, Neg}; +pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not}; pub use ops::{BitAnd, BitOr, BitXor}; pub use ops::{Shl, Shr, Index}; diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 22c363ba9c0..36293d6a1c0 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -48,6 +48,11 @@ pub trait Neg<Result> { pure fn neg(&self) -> Result; } +#[lang="not"] +pub trait Not<Result> { + pure fn not(&self) -> Result; +} + #[lang="bitand"] pub trait BitAnd<RHS,Result> { pure fn bitand(&self, rhs: &RHS) -> Result; @@ -77,4 +82,3 @@ pub trait Shr<RHS,Result> { pub trait Index<Index,Result> { pure fn index(&self, index: Index) -> Result; } - diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index f2f6659278d..de23feceea5 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -4,7 +4,7 @@ pub use kinds::{Const, Copy, Owned, Durable}; pub use ops::{Drop}; -pub use ops::{Add, Sub, Mul, Div, Modulo, Neg}; +pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not}; pub use ops::{BitAnd, BitOr, BitXor}; pub use ops::{Shl, Shr, Index}; pub use option::{Option, Some, None}; |
