Simplify int_in_range

This commit is contained in:
Jonas Schievink 2021-08-31 13:11:17 +02:00
parent 8969cbb22f
commit 8c9de51fa3

View file

@ -133,13 +133,13 @@ fn next_cfg_expr(it: &mut SliceIter<tt::TokenTree>) -> Option<CfgExpr> {
#[cfg(test)] #[cfg(test)]
impl arbitrary::Arbitrary<'_> for CfgAtom { impl arbitrary::Arbitrary<'_> for CfgAtom {
fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> { fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
match u.int_in_range(0..=1)? { if u.arbitrary()? {
0 => Ok(CfgAtom::Flag(String::arbitrary(u)?.into())), Ok(CfgAtom::Flag(String::arbitrary(u)?.into()))
1 => Ok(CfgAtom::KeyValue { } else {
Ok(CfgAtom::KeyValue {
key: String::arbitrary(u)?.into(), key: String::arbitrary(u)?.into(),
value: String::arbitrary(u)?.into(), value: String::arbitrary(u)?.into(),
}), })
_ => unreachable!(),
} }
} }
} }