diff --git a/src/bin/bitart/expression.rs b/src/bin/bitart/expression.rs index 64085ce..176ec6c 100644 --- a/src/bin/bitart/expression.rs +++ b/src/bin/bitart/expression.rs @@ -56,10 +56,15 @@ impl fmt::Display for Variable { pub enum UnaryOperator { Negation, Complement, + ReverseBits, } impl UnaryOperator { - const VALUES: &[UnaryOperator] = &[UnaryOperator::Negation, UnaryOperator::Complement]; + const VALUES: &[UnaryOperator] = &[ + UnaryOperator::Negation, + UnaryOperator::Complement, + UnaryOperator::ReverseBits, + ]; fn random(rng: &mut R) -> UnaryOperator { let values = Self::VALUES; @@ -70,6 +75,7 @@ impl UnaryOperator { match self { UnaryOperator::Negation => -operand, UnaryOperator::Complement => !operand, + UnaryOperator::ReverseBits => operand.reverse_bits(), } } } @@ -78,8 +84,8 @@ impl fmt::Display for UnaryOperator { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { UnaryOperator::Negation => write!(f, "-"), - // We use C syntax for `Display`. UnaryOperator::Complement => write!(f, "~"), + UnaryOperator::ReverseBits => write!(f, "r"), } } }