From 8c9de51fa354f7d2486ba8b89129daedbbb62155 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 31 Aug 2021 13:11:17 +0200 Subject: [PATCH] Simplify `int_in_range` --- crates/cfg/src/cfg_expr.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/cfg/src/cfg_expr.rs b/crates/cfg/src/cfg_expr.rs index c980e9642ac..2158fb9f2dc 100644 --- a/crates/cfg/src/cfg_expr.rs +++ b/crates/cfg/src/cfg_expr.rs @@ -133,13 +133,13 @@ fn next_cfg_expr(it: &mut SliceIter) -> Option { #[cfg(test)] impl arbitrary::Arbitrary<'_> for CfgAtom { fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { - match u.int_in_range(0..=1)? { - 0 => Ok(CfgAtom::Flag(String::arbitrary(u)?.into())), - 1 => Ok(CfgAtom::KeyValue { + if u.arbitrary()? { + Ok(CfgAtom::Flag(String::arbitrary(u)?.into())) + } else { + Ok(CfgAtom::KeyValue { key: String::arbitrary(u)?.into(), value: String::arbitrary(u)?.into(), - }), - _ => unreachable!(), + }) } } }