# Trait bitflags::__core::ops::Neg [−] [src]

    pub trait Neg {
        type Output;
        fn neg(self) -> Self::Output;
    }

The `Neg` trait is used to specify the functionality of unary `-`.

# Examples

A trivial implementation of `Neg`. When `-Foo` happens, it ends up calling `neg`, and therefore, `main` prints `Negating!`.

    use std::ops::Neg;

    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

## Required Methods

### `fn neg(self) -> Self::Output`

The method for the unary `-` operator

## Implementors

- `impl Neg for isize`
- `impl<'a> Neg for &'a isize`
- `impl Neg for i8`
- `impl<'a> Neg for &'a i8`
- `impl Neg for i16`
- `impl<'a> Neg for &'a i16`
- `impl Neg for i32`
- `impl<'a> Neg for &'a i32`
- `impl Neg for i64`
- `impl<'a> Neg for &'a i64`
- `impl Neg for f32`
- `impl<'a> Neg for &'a f32`
- `impl Neg for f64`
- `impl<'a> Neg for &'a f64`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)