safe transmute: tweak Nfa::union to consume params by value

ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925274516
This commit is contained in:
Jack Wrenn 2022-07-21 18:22:04 +00:00
parent b78c3daad0
commit 2268603046

View File

@ -92,7 +92,7 @@ where
let mut alts = alts.into_iter().map(Self::from_tree); let mut alts = alts.into_iter().map(Self::from_tree);
let mut nfa = alts.next().ok_or(Uninhabited)??; let mut nfa = alts.next().ok_or(Uninhabited)??;
for alt in alts { for alt in alts {
nfa = nfa.union(&alt?); nfa = nfa.union(alt?);
} }
nfa nfa
} }
@ -136,7 +136,7 @@ where
} }
/// Compute the union of two `Nfa`s. /// Compute the union of two `Nfa`s.
pub(crate) fn union(&self, other: &Self) -> Self { pub(crate) fn union(self, other: Self) -> Self {
let start = self.start; let start = self.start;
let accepting = self.accepting; let accepting = self.accepting;