Trait core::ops::Neg
[−]
[src]
pub trait Neg {
type Output;
fn neg(self) -> Self::Output;
}The Neg`Negtrait is used to specify the functionality of unary` trait is used to specify the functionality of unary -`-`.
Examples
A trivial implementation of Neg`Neg. When`. When -Foo`-Foohappens, it ends up calling` happens, it ends up calling
neg`neg, and therefore,`, and therefore, main`mainprints` prints Negating!`Negating!`.
use std::ops::Neg; #[derive(Copy, Clone)] struct Foo; impl Neg for Foo { type Output = Foo; fn neg(self) -> Foo { println!("Negating!"); self } } fn main() { -Foo; }
Associated Types
type Output
The resulting type after applying the -`-` operator