style: adjust the enum variant length
This commit is contained in:
parent
84f8b2a093
commit
f23371ac39
2 changed files with 15 additions and 27 deletions
|
|
@ -1,7 +1,5 @@
|
||||||
use std::{
|
use std::collections::HashSet;
|
||||||
collections::HashSet,
|
use std::ops::{Add, BitAnd, BitOr, Div, Mul, Neg, Not};
|
||||||
ops::{Add, BitAnd, BitOr, Div, Mul, Neg, Not},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub(crate) mod internal_macros;
|
pub(crate) mod internal_macros;
|
||||||
|
|
||||||
|
|
@ -36,30 +34,18 @@ pub enum Ordering {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum BoolExpr {
|
pub enum BoolExpr {
|
||||||
BoolLit(bool),
|
BoolLit(bool),
|
||||||
BoolVar {
|
BoolVar { name: String },
|
||||||
name: String,
|
Cmp { op: Ordering, lhs: Box<NumExpr>, rhs: Box<NumExpr> },
|
||||||
},
|
Not { arg: Box<BoolExpr> },
|
||||||
Cmp {
|
And { args: Vec<BoolExpr> },
|
||||||
op: Ordering,
|
Or { args: Vec<BoolExpr> },
|
||||||
lhs: Box<NumExpr>,
|
|
||||||
rhs: Box<NumExpr>,
|
|
||||||
},
|
|
||||||
Not {
|
|
||||||
arg: Box<BoolExpr>,
|
|
||||||
},
|
|
||||||
And {
|
|
||||||
args: Vec<BoolExpr>,
|
|
||||||
},
|
|
||||||
Or {
|
|
||||||
args: Vec<BoolExpr>,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Expression builder
|
/// Expression builder
|
||||||
///
|
///
|
||||||
/// The `ExprBuilder` is a factory structure that deals with the creation of expressions.
|
/// The `ExprBuilder` is a factory structure that deals with the creation of
|
||||||
/// The main goal of this is to ensure users do not create duplicate definitions for
|
/// expressions. The main goal of this is to ensure users do not create duplicate
|
||||||
/// variables.
|
/// definitions for variables.
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
pub struct ExprBuilder {
|
pub struct ExprBuilder {
|
||||||
declarations: HashSet<String>,
|
declarations: HashSet<String>,
|
||||||
|
|
@ -365,9 +351,10 @@ internal_macros::forward_box_binop! {impl BitAnd, bitand for BoolExpr, BoolExpr
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod arbitrary {
|
pub mod arbitrary {
|
||||||
//! Helper functions to generate arbitrary expressions using [`proptest`].
|
//! Helper functions to generate arbitrary expressions using [`proptest`].
|
||||||
use super::*;
|
|
||||||
use proptest::prelude::*;
|
use proptest::prelude::*;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
pub fn num_expr() -> impl Strategy<Value = Box<NumExpr>> {
|
pub fn num_expr() -> impl Strategy<Value = Box<NumExpr>> {
|
||||||
let leaf = prop_oneof![
|
let leaf = prop_oneof![
|
||||||
any::<i64>().prop_map(|val| Box::new(NumExpr::IntLit(val))),
|
any::<i64>().prop_map(|val| Box::new(NumExpr::IntLit(val))),
|
||||||
|
|
@ -443,10 +430,11 @@ pub mod arbitrary {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
use paste::paste;
|
use paste::paste;
|
||||||
use proptest::prelude::*;
|
use proptest::prelude::*;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
proptest! {
|
proptest! {
|
||||||
#[test]
|
#[test]
|
||||||
fn correctly_create_num_expr(num_expr in arbitrary::num_expr()) {
|
fn correctly_create_num_expr(num_expr in arbitrary::num_expr()) {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@ group_imports = "StdExternalCrate"
|
||||||
imports_granularity = "Module"
|
imports_granularity = "Module"
|
||||||
condense_wildcard_suffixes = true
|
condense_wildcard_suffixes = true
|
||||||
use_field_init_shorthand = true
|
use_field_init_shorthand = true
|
||||||
struct_variant_width = 45
|
struct_variant_width = 65
|
||||||
|
|
||||||
unstable_features = true
|
unstable_features = true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue