Trait scale_info::prelude::ops::Not

1.0.0 · source · []
pub trait Not {
    type Output;
    fn not(self) -> Self::Output;
}
Expand description

The unary logical negation operator !.

Examples

An implementation of Not for Answer, which enables the use of ! to invert its value.

use std::ops::Not;

#[derive(Debug, PartialEq)]
enum Answer {
    Yes,
    No,
}

impl Not for Answer {
    type Output = Self;

    fn not(self) -> Self::Output {
        match self {
            Answer::Yes => Answer::No,
            Answer::No => Answer::Yes
        }
    }
}

assert_eq!(!Answer::Yes, Answer::No);
assert_eq!(!Answer::No, Answer::Yes);

Associated Types

The resulting type after applying the ! operator.

Required methods

Performs the unary ! operation.

Examples
assert_eq!(!true, false);
assert_eq!(!false, true);
assert_eq!(!1u8, 254);
assert_eq!(!0u8, 255);

Implementations on Foreign Types

This implementation inverts all elements in the live buffer. You cannot rely on the value of bits in the buffer that are outside the domain of BitVec::as_mit_bitslice.

Implementors

impl<O, V> Not for BitArray<O, V> where
    O: BitOrder,
    V: BitView

impl<R> Not for BitMask<R> where
    R: BitRegister

impl<M, O, T> Not for BitRef<'_, M, O, T> where
    M: Mutability,
    O: BitOrder,
    T: BitStore

impl<'a, O, T> Not for &'a mut BitSlice<O, T> where
    O: BitOrder,
    T: BitStore

impl<O, T> Not for BitBox<O, T> where
    O: BitOrder,
    T: BitStore

impl<O, T> Not for BitVec<O, T> where
    O: BitOrder,
    T: BitStore

impl Not for U128

impl Not for U256

impl Not for U512

impl Not for Capabilities

impl Not for Choice

impl Not for B0

impl Not for B1