Trait scale_info::prelude::ops::Not
1.0.0 · source · pub trait Not {
type Output;
// Required method
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);
Required Associated Types§
Required Methods§
Implementors§
1.74.0 · source§impl Not for Saturating<i8>
impl Not for Saturating<i8>
type Output = Saturating<i8>
1.74.0 · source§impl Not for Saturating<i16>
impl Not for Saturating<i16>
type Output = Saturating<i16>
1.74.0 · source§impl Not for Saturating<i32>
impl Not for Saturating<i32>
type Output = Saturating<i32>
1.74.0 · source§impl Not for Saturating<i64>
impl Not for Saturating<i64>
type Output = Saturating<i64>
1.74.0 · source§impl Not for Saturating<i128>
impl Not for Saturating<i128>
type Output = Saturating<i128>
1.74.0 · source§impl Not for Saturating<isize>
impl Not for Saturating<isize>
type Output = Saturating<isize>
1.74.0 · source§impl Not for Saturating<u8>
impl Not for Saturating<u8>
type Output = Saturating<u8>
1.74.0 · source§impl Not for Saturating<u16>
impl Not for Saturating<u16>
type Output = Saturating<u16>
1.74.0 · source§impl Not for Saturating<u32>
impl Not for Saturating<u32>
type Output = Saturating<u32>
1.74.0 · source§impl Not for Saturating<u64>
impl Not for Saturating<u64>
type Output = Saturating<u64>
1.74.0 · source§impl Not for Saturating<u128>
impl Not for Saturating<u128>
type Output = Saturating<u128>
1.74.0 · source§impl Not for Saturating<usize>
impl Not for Saturating<usize>
type Output = Saturating<usize>
source§impl<'a, T, O> Not for &'a mut BitSlice<T, O>
impl<'a, T, O> Not for &'a mut BitSlice<T, O>
Inverts each bit in the bit-slice.
Unlike the &
, |
, and ^
operators, this implementation is guaranteed to
update each memory element only once, and is not required to traverse every live
bit in the underlying region.
source§impl<T, O> Not for BitVec<T, O>
impl<T, O> Not for BitVec<T, O>
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_mut_bitslice
.