pub struct Signed<const W: u32>(/* private fields */);Expand description
Signed bitvector.
The width (number of bits) is specified in the generic parameter W.
Signed bitvectors support bitwise operations and wrapping-arithmetic operations.
Arithmetic bit extension is also possible (the sign bit is copied into any bits above it).
Signed bitvectors can be converted into Unsigned or Bitvector.
Implementations§
Trait Implementations§
Source§impl<const W: u32> Div for Signed<W>
impl<const W: u32> Div for Signed<W>
Source§impl<const W: u32> Ord for Signed<W>
impl<const W: u32> Ord for Signed<W>
Source§impl<const W: u32> PartialOrd for Signed<W>
impl<const W: u32> PartialOrd for Signed<W>
Source§impl<const W: u32> Shl for Signed<W>
impl<const W: u32> Shl for Signed<W>
Source§fn shl(self, rhs: Signed<W>) -> Self::Output
fn shl(self, rhs: Signed<W>) -> Self::Output
Performs a left shift.
Unlike a right shift, where the behaviour is dependent on signedness, the left shift has the same behaviour: shifted-out bits on the left are discarded and zeros are shifted in on the right.
The right-hand side operand is interpreted as unsigned and if it
is equal or greater to the bit-width, the result is all-zeros,
as in Rust unbounded_shl. It is planned to restrict the bit-width
in the future so that this edge case can never occur.
Note that this means that shifting left with a negative right operand produces an all-zeros value.
Source§impl<const W: u32> Shr for Signed<W>
impl<const W: u32> Shr for Signed<W>
Source§fn shr(self, rhs: Signed<W>) -> Self::Output
fn shr(self, rhs: Signed<W>) -> Self::Output
Performs an arithmetic right shift.
The right-hand side operand is interpreted as unsigned and if it
is equal or greater to the bit-width, the result is all-zeros or
all-ones depending on the original sign bit, as in Rust unbounded_shr
on signed primitives.
It is planned to restrict the bit-width in the future so that this edge
case can never occur.
Note that this means that shifting right with a negative right operand produces an all-zeros or all-ones value, depending on the original sign bit.
impl<const W: u32> Copy for Signed<W>
impl<const W: u32> Eq for Signed<W>
impl<const W: u32> StructuralPartialEq for Signed<W>
Auto Trait Implementations§
impl<const W: u32> Freeze for Signed<W>
impl<const W: u32> RefUnwindSafe for Signed<W>
impl<const W: u32> Send for Signed<W>
impl<const W: u32> Sync for Signed<W>
impl<const W: u32> Unpin for Signed<W>
impl<const W: u32> UnwindSafe for Signed<W>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more