pub trait SignedNumeric: Numeric {
// Required methods
fn is_negative(self) -> bool;
fn as_negative(self, bits: u32) -> Self;
fn as_negative_fixed<const BITS: u32>(self) -> Self;
fn as_unsigned(self, bits: u32) -> Self;
fn as_unsigned_fixed<const BITS: u32>(self) -> Self;
fn signed_value(self) -> SignedValue;
}
Expand description
This trait extends many common signed integer types so that they can be used with the bitstream handling traits.
Required Methods§
Sourcefn is_negative(self) -> bool
fn is_negative(self) -> bool
Returns true if this value is negative
Sourcefn as_negative(self, bits: u32) -> Self
fn as_negative(self, bits: u32) -> Self
Given a two-complement positive value and certain number of bits, returns this value as a negative number.
Sourcefn as_negative_fixed<const BITS: u32>(self) -> Self
fn as_negative_fixed<const BITS: u32>(self) -> Self
Given a two-complement positive value and certain number of bits, returns this value as a negative number.
Sourcefn as_unsigned(self, bits: u32) -> Self
fn as_unsigned(self, bits: u32) -> Self
Given a negative value and a certain number of bits, returns this value as a twos-complement positive number.
Sourcefn as_unsigned_fixed<const BITS: u32>(self) -> Self
fn as_unsigned_fixed<const BITS: u32>(self) -> Self
Given a negative value and a certain number of bits, returns this value as a twos-complement positive number.
Sourcefn signed_value(self) -> SignedValue
fn signed_value(self) -> SignedValue
Converts to a generic signed value for stream recording purposes.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.