1
Fork 0

Replace a try_fold in rustc_transmute to use ControlFlow instead of Result

This commit is contained in:
David Tolnay 2022-08-15 16:21:39 -07:00
parent 83f081fc01
commit 39809c5f68
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82

View file

@ -1,4 +1,5 @@
use super::{Byte, Def, Ref}; use super::{Byte, Def, Ref};
use std::ops::ControlFlow;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
@ -90,13 +91,13 @@ where
Tree::unit(), Tree::unit(),
|elts, elt| { |elts, elt| {
if elt == Tree::uninhabited() { if elt == Tree::uninhabited() {
Err(Tree::uninhabited()) ControlFlow::Break(Tree::uninhabited())
} else { } else {
Ok(elts.then(elt)) ControlFlow::Continue(elts.then(elt))
} }
}, },
) { ) {
Err(node) | Ok(node) => node, ControlFlow::Break(node) | ControlFlow::Continue(node) => node,
}, },
Self::Alt(alts) => alts Self::Alt(alts) => alts
.into_iter() .into_iter()