#[repr(u8)]pub enum Shift {
Error = 0,
Mask = 1,
Saturate = 2,
}Expand description
The shift policy: what shl and shr do when the amount is at least
the bit width, or negative for a signed amount.
§Examples
use bytecode_lang::Shift;
assert_eq!(Shift::default(), Shift::Error);
assert_eq!(Shift::from_code(2), Some(Shift::Saturate));
assert_eq!(Shift::from_code(3), None);Variants§
Error = 0
Raise ShiftOutOfRange (E0003) through the language’s error model.
Mask = 1
Use the amount modulo the width (n & (width - 1)); never an error.
Saturate = 2
PHP’s rule (OPS v2): an amount at or above the width gives 0
(shr of a negative signed value gives -1); a negative
amount is still ShiftOutOfRange (E0003), never masked.
Implementations§
Trait Implementations§
impl Copy for Shift
impl Eq for Shift
Source§impl Ord for Shift
impl Ord for Shift
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Shift
impl PartialOrd for Shift
impl StructuralPartialEq for Shift
Auto Trait Implementations§
impl Freeze for Shift
impl RefUnwindSafe for Shift
impl Send for Shift
impl Sync for Shift
impl Unpin for Shift
impl UnsafeUnpin for Shift
impl UnwindSafe for Shift
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
Mutably borrows from an owned value. Read more