pub unsafe trait ValidCheck<P> {
const ALWAYS_VALID: bool = false;
// Provided method
fn is_valid(_input: P) -> bool { ... }
}
Expand description
Check whether the underlying bits are valid
The type implementing this trait checks if the value stored in a bit
representation of type P
is a valid representation of this type. The
enums
macro implements this type for all of the integer-byte-width types
from this crate.
§Safety
The ValidCheck::is_valid
function must be correctly implemented or else
other functions in this crate won’t work correctly. Implementation of this
trait is preferably done by public macros in this crate, which will
implement it correctly.
Provided Associated Constants§
Sourceconst ALWAYS_VALID: bool = false
const ALWAYS_VALID: bool = false
Set this to true if, at compile-time, we can tell that all bit representations which contain the appropriate number of bits are valid representations of this type
Provided Methods§
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.