@@ -260,39 +260,50 @@ impl Condition {
260260 pub fn len ( & self ) -> usize {
261261 self . conditions . len ( )
262262 }
263+ }
263264
264- pub ( crate ) fn to_simple_expr ( & self ) -> SimpleExpr {
265+ impl From < Condition > for SimpleExpr {
266+ fn from ( cond : Condition ) -> Self {
265267 let mut inner_exprs = vec ! [ ] ;
266- for ce in & self . conditions {
268+ for ce in cond . conditions {
267269 inner_exprs. push ( match ce {
268- ConditionExpression :: Condition ( c) => c. to_simple_expr ( ) ,
269- ConditionExpression :: SimpleExpr ( e) => e. clone ( ) ,
270+ ConditionExpression :: Condition ( c) => c. into ( ) ,
271+ ConditionExpression :: SimpleExpr ( e) => e,
270272 } ) ;
271273 }
272274 let mut inner_exprs_into_iter = inner_exprs. into_iter ( ) ;
273275 let expr = if let Some ( first_expr) = inner_exprs_into_iter. next ( ) {
274276 let mut out_expr = first_expr;
275277 for e in inner_exprs_into_iter {
276- out_expr = match self . condition_type {
278+ out_expr = match cond . condition_type {
277279 ConditionType :: Any => out_expr. or ( e) ,
278280 ConditionType :: All => out_expr. and ( e) ,
279281 } ;
280282 }
281283 out_expr
282284 } else {
283- SimpleExpr :: Constant ( match self . condition_type {
285+ SimpleExpr :: Constant ( match cond . condition_type {
284286 ConditionType :: Any => false . into ( ) ,
285287 ConditionType :: All => true . into ( ) ,
286288 } )
287289 } ;
288- if self . negate {
290+ if cond . negate {
289291 expr. not ( )
290292 } else {
291293 expr
292294 }
293295 }
294296}
295297
298+ impl From < ConditionExpression > for SimpleExpr {
299+ fn from ( ce : ConditionExpression ) -> Self {
300+ match ce {
301+ ConditionExpression :: Condition ( c) => c. into ( ) ,
302+ ConditionExpression :: SimpleExpr ( e) => e,
303+ }
304+ }
305+ }
306+
296307impl From < Condition > for ConditionExpression {
297308 fn from ( condition : Condition ) -> Self {
298309 ConditionExpression :: Condition ( condition)
0 commit comments