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 std::ops::ControlFlow;
#[cfg(test)]
mod tests;
@ -90,13 +91,13 @@ where
Tree::unit(),
|elts, elt| {
if elt == Tree::uninhabited() {
Err(Tree::uninhabited())
ControlFlow::Break(Tree::uninhabited())
} 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
.into_iter()