Trait core::ops::NegExperimental
[-]
[+]
[src]
pub trait Neg<Result> { fn neg(self) -> Result; }
The Neg
trait is used to specify the functionality of unary -
.
Example
A trivial implementation of Neg
. When -Foo
happens, it ends up calling
neg
, and therefore, main
prints Negating!
.
struct Foo; impl Copy for Foo {} impl Neg<Foo> for Foo { fn neg(self) -> Foo { println!("Negating!"); self } } fn main() { -Foo; }
Required Methods
fn neg(self) -> Result
The method for the unary -
operator