From 0853e97f17c2bc9f2c241a1d4556d4524fa51895 Mon Sep 17 00:00:00 2001 From: adamnemecek Date: Sat, 3 May 2025 17:00:53 -0700 Subject: [PATCH 1/2] ran `cargo clippy --fix -- -Wclippy::use_self` --- crates/automata-core/src/alphabet.rs | 2 +- .../src/alphabet/propositional.rs | 14 +-- crates/automata-core/src/alphabet/simple.rs | 32 +++---- crates/automata-core/src/word/finite.rs | 4 +- crates/automata-core/src/word/omega.rs | 4 +- .../automata-learning/src/passive/precise.rs | 2 +- .../automata-learning/src/passive/sample.rs | 12 +-- crates/automata/src/automaton.rs | 8 +- crates/automata/src/automaton/omega.rs | 8 +- crates/automata/src/congruence/cayley.rs | 2 +- .../src/congruence/transitionprofile.rs | 14 +-- crates/automata/src/dot.rs | 11 +-- crates/automata/src/hoa/input.rs | 6 +- crates/automata/src/hoa/output.rs | 4 +- crates/automata/src/ts.rs | 2 +- crates/automata/src/ts/builder.rs | 4 +- .../automata/src/ts/connected_components.rs | 2 +- crates/automata/src/ts/path.rs | 6 +- crates/automata/src/ts/run.rs | 24 ++--- crates/hoars/src/body.rs | 6 +- crates/hoars/src/format.rs | 88 ++++++++--------- crates/hoars/src/header.rs | 10 +- crates/hoars/src/label.rs | 24 ++--- crates/hoars/src/lexer.rs | 26 ++--- crates/hoars/src/lib.rs | 28 +++--- crates/hoars/src/output.rs | 94 +++++++++---------- 26 files changed, 218 insertions(+), 219 deletions(-) diff --git a/crates/automata-core/src/alphabet.rs b/crates/automata-core/src/alphabet.rs index ad9dc19..b2adea7 100644 --- a/crates/automata-core/src/alphabet.rs +++ b/crates/automata-core/src/alphabet.rs @@ -182,7 +182,7 @@ impl Iterator for FreeMonoid { } if carry { - self.current = std::iter::repeat(0).take(self.current.len() + 1).collect(); + self.current = std::iter::repeat_n(0, self.current.len() + 1).collect(); } Some(out) diff --git a/crates/automata-core/src/alphabet/propositional.rs b/crates/automata-core/src/alphabet/propositional.rs index a06afd2..807993c 100644 --- a/crates/automata-core/src/alphabet/propositional.rs +++ b/crates/automata-core/src/alphabet/propositional.rs @@ -148,7 +148,7 @@ impl PropExpression { _ty: PhantomData, } } - pub fn new(num_aps: u8, string: &str) -> PropExpression { + pub fn new(num_aps: u8, string: &str) -> Self { let vars = BddVariableSet::new_anonymous(num_aps as u16); Self::from_parts(num_aps, vars.eval_expression_string(string)) } @@ -189,11 +189,11 @@ impl PropExpression { } impl std::ops::BitAnd for PropExpression { - type Output = PropExpression; + type Output = Self; fn bitand(self, rhs: Self) -> Self::Output { assert_eq!(self.num_aps, rhs.num_aps); - PropExpression { + Self { num_aps: self.num_aps, bdd: self.bdd.and(&rhs.bdd), _ty: PhantomData, @@ -201,7 +201,7 @@ impl std::ops::BitAnd for PropExpression { } } impl std::ops::Not for PropExpression { - type Output = PropExpression; + type Output = Self; fn not(self) -> Self::Output { Self::from_parts(self.num_aps, self.bdd.not()) @@ -209,7 +209,7 @@ impl std::ops::Not for PropExpression { } impl std::ops::BitOr for PropExpression { - type Output = PropExpression; + type Output = Self; fn bitor(self, rhs: Self) -> Self::Output { assert_eq!(self.num_aps, rhs.num_aps); Self::from_parts(self.num_aps, self.bdd.or(&rhs.bdd)) @@ -285,8 +285,8 @@ impl Matcher> for PropSymbol } } -impl Matcher> for PropExpression { - fn matches(&self, expression: &PropExpression) -> bool { +impl Matcher for PropExpression { + fn matches(&self, expression: &Self) -> bool { assert_eq!(self.num_aps, expression.num_aps); // all values in self should also be in expression // we share nothing with the complement of the expression diff --git a/crates/automata-core/src/alphabet/simple.rs b/crates/automata-core/src/alphabet/simple.rs index d29fd2a..150d6ce 100644 --- a/crates/automata-core/src/alphabet/simple.rs +++ b/crates/automata-core/src/alphabet/simple.rs @@ -69,16 +69,16 @@ impl CharAlphabet { } } -impl Matcher for char { - fn matches(&self, expression: &char) -> bool { +impl Matcher for char { + fn matches(&self, expression: &Self) -> bool { self == expression } } impl Expression for char { - type S = char; + type S = Self; type SymbolsIter<'this> - = std::iter::Once + = std::iter::Once where Self: 'this; fn symbols(&self) -> Self::SymbolsIter<'_> { @@ -88,11 +88,11 @@ impl Expression for char { self == other } - fn for_each(&self, f: F) { + fn for_each(&self, f: F) { (f)(*self) } - fn matched_by(&self, symbol: char) -> bool { + fn matched_by(&self, symbol: Self) -> bool { self == &symbol } } @@ -163,16 +163,16 @@ impl SimpleAlphabet for CharAlphabet { #[derive(Clone, Debug)] pub struct Fixed([S; N]); -impl Matcher for usize { - fn matches(&self, expression: &usize) -> bool { +impl Matcher for usize { + fn matches(&self, expression: &Self) -> bool { self == expression } } impl Expression for usize { - type S = usize; + type S = Self; type SymbolsIter<'this> - = std::iter::Once + = std::iter::Once where Self: 'this; @@ -183,7 +183,7 @@ impl Expression for usize { self == other } - fn matched_by(&self, symbol: usize) -> bool { + fn matched_by(&self, symbol: Self) -> bool { *self == symbol } } @@ -260,16 +260,16 @@ impl InvertibleChar { } } -impl Matcher for InvertibleChar { - fn matches(&self, expression: &InvertibleChar) -> bool { +impl Matcher for InvertibleChar { + fn matches(&self, expression: &Self) -> bool { self == expression } } impl Expression for InvertibleChar { - type S = InvertibleChar; + type S = Self; type SymbolsIter<'this> - = std::iter::Once + = std::iter::Once where Self: 'this; @@ -280,7 +280,7 @@ impl Expression for InvertibleChar { self == other } - fn matched_by(&self, symbol: InvertibleChar) -> bool { + fn matched_by(&self, symbol: Self) -> bool { *self == symbol } } diff --git a/crates/automata-core/src/word/finite.rs b/crates/automata-core/src/word/finite.rs index a3ff173..4fe743c 100644 --- a/crates/automata-core/src/word/finite.rs +++ b/crates/automata-core/src/word/finite.rs @@ -282,10 +282,10 @@ impl FiniteWord for Vec { self.iter().cloned() } - fn collect_vec(&self) -> Vec { + fn collect_vec(&self) -> Self { self.clone() } - fn into_vec(self) -> Vec { + fn into_vec(self) -> Self { self } diff --git a/crates/automata-core/src/word/omega.rs b/crates/automata-core/src/word/omega.rs index 70ac189..7147f6c 100644 --- a/crates/automata-core/src/word/omega.rs +++ b/crates/automata-core/src/word/omega.rs @@ -206,8 +206,8 @@ impl From<&PeriodicOmegaWord> for ReducedOmegaWord { } } -impl From<&ReducedOmegaWord> for ReducedOmegaWord { - fn from(value: &ReducedOmegaWord) -> Self { +impl From<&Self> for ReducedOmegaWord { + fn from(value: &Self) -> Self { Self::ultimately_periodic(value.spoke(), value.cycle()) } } diff --git a/crates/automata-learning/src/passive/precise.rs b/crates/automata-learning/src/passive/precise.rs index 6064948..cbefd8c 100644 --- a/crates/automata-learning/src/passive/precise.rs +++ b/crates/automata-learning/src/passive/precise.rs @@ -472,7 +472,7 @@ impl From> for PreciseDPA { start.elapsed().as_micros() ); - PreciseDPA::new(leading, prc_dfas) + Self::new(leading, prc_dfas) } } diff --git a/crates/automata-learning/src/passive/sample.rs b/crates/automata-learning/src/passive/sample.rs index f6cbac1..7817674 100644 --- a/crates/automata-learning/src/passive/sample.rs +++ b/crates/automata-learning/src/passive/sample.rs @@ -102,31 +102,31 @@ impl> SetSample { } } - pub fn into_joined(self, other: SetSample) -> SetSample { - let SetSample { + pub fn into_joined(self, other: Self) -> Self { + let Self { alphabet, mut positive, mut negative, } = self; positive.extend(other.positive); negative.extend(other.negative); - SetSample { + Self { positive, negative, alphabet, } } - pub fn append(&mut self, other: SetSample) { + pub fn append(&mut self, other: Self) { self.positive.extend(other.positive); self.negative.extend(other.negative); } - pub fn as_joined(&self, other: &SetSample) -> SetSample + pub fn as_joined(&self, other: &Self) -> Self where W: Clone, { - SetSample { + Self { alphabet: self.alphabet.clone(), positive: self .positive diff --git a/crates/automata/src/automaton.rs b/crates/automata/src/automaton.rs index 9462c51..5cdeb9c 100644 --- a/crates/automata/src/automaton.rs +++ b/crates/automata/src/automaton.rs @@ -116,7 +116,7 @@ where pub fn new_with_initial_color( alphabet: A, initial_color: Q, - ) -> Automaton + ) -> Self where D: ForAlphabet + Sproutable, Z: Default, @@ -133,7 +133,7 @@ where alphabet: A, initial_color: Q, edge_color: C, - ) -> Automaton + ) -> Self where D: ForAlphabet + Sproutable, Z: Default, @@ -276,7 +276,7 @@ where } } -impl AsRef> +impl AsRef for Automaton where A: Alphabet, @@ -284,7 +284,7 @@ where Q: Color, C: Color, { - fn as_ref(&self) -> &Automaton { + fn as_ref(&self) -> &Self { self } } diff --git a/crates/automata/src/automaton/omega.rs b/crates/automata/src/automaton/omega.rs index e4c9b70..cc723f8 100644 --- a/crates/automata/src/automaton/omega.rs +++ b/crates/automata/src/automaton/omega.rs @@ -59,7 +59,7 @@ impl OmegaAcceptanceCondition { /// [`AcceptanceMask`]s. pub fn satisfied(&self, infset: &OrderedSet) -> bool { match self { - OmegaAcceptanceCondition::Parity(_low, _high) => infset + Self::Parity(_low, _high) => infset .iter() .map(|x| x.as_priority()) .min() @@ -77,7 +77,7 @@ impl OmegaAutomaton { ts: TS, initial: DefaultIdType, acceptance: OmegaAcceptanceCondition, - ) -> OmegaAutomaton { + ) -> Self { OmegaAutomaton { ts, initial, @@ -179,7 +179,7 @@ impl From> for DeterministicOmegaAutom }) })) .into_dts(); - DeterministicOmegaAutomaton::new(ts, value.initial, value.acceptance) + Self::new(ts, value.initial, value.acceptance) } } @@ -214,7 +214,7 @@ impl TryFrom> } assert!(value.initial().into_usize() < size); - Ok(DeterministicOmegaAutomaton::new( + Ok(Self::new( ts, value.initial, value.acceptance, diff --git a/crates/automata/src/congruence/cayley.rs b/crates/automata/src/congruence/cayley.rs index 2e149c0..cec8740 100644 --- a/crates/automata/src/congruence/cayley.rs +++ b/crates/automata/src/congruence/cayley.rs @@ -121,7 +121,7 @@ where /// Build a new Cayley graph from the given transition system. pub fn new(ts: Ts) -> Self { let alphabet = Directional::from_iter(ts.alphabet().universe()); - Cayley { + Self { expressions: alphabet.expression_map(), m: TransitionMonoid::new(ts), alphabet, diff --git a/crates/automata/src/congruence/transitionprofile.rs b/crates/automata/src/congruence/transitionprofile.rs index ae1bbf0..f2200ce 100644 --- a/crates/automata/src/congruence/transitionprofile.rs +++ b/crates/automata/src/congruence/transitionprofile.rs @@ -91,14 +91,14 @@ impl Accumulates for Void { fn update(&mut self, _other: &Self) {} fn neutral() -> Self { - Void + Self } fn from_iter<'a, I: IntoIterator>(_iter: I) -> Self where Self: 'a, { - Void + Self } fn from(x: Self) -> Self { @@ -116,14 +116,14 @@ impl Accumulates for usize { } fn neutral() -> Self { - usize::MAX + Self::MAX } fn from_iter<'a, I: IntoIterator>(iter: I) -> Self where Self: 'a, { - iter.into_iter().cloned().min().unwrap_or(usize::MAX) + iter.into_iter().cloned().min().unwrap_or(Self::MAX) } fn from(x: Self) -> Self { @@ -366,12 +366,12 @@ where 0..self.tps.len() } - fn build(ts: Ts) -> TransitionMonoid { + fn build(ts: Ts) -> Self { let indices = ts.state_indices().collect(); Self::build_for_states(ts, indices) } - fn build_for_states(ts: Ts, states: Vec) -> TransitionMonoid { + fn build_for_states(ts: Ts, states: Vec) -> Self { let eps_profile = RunProfile::empty_for_states(states); let mut tps = vec![(eps_profile.clone(), 0)]; let mut strings = vec![(vec![], ProfileEntry::Profile(0))]; @@ -405,7 +405,7 @@ where } } - TransitionMonoid { ts, tps, strings } + Self { ts, tps, strings } } } diff --git a/crates/automata/src/dot.rs b/crates/automata/src/dot.rs index 9ae2d15..3a56be1 100644 --- a/crates/automata/src/dot.rs +++ b/crates/automata/src/dot.rs @@ -216,8 +216,7 @@ pub trait Dottable: TransitionSystem { .arg(tempfile_name) .spawn()?; if !child.wait()?.success() { - Err(std::io::Error::new( - std::io::ErrorKind::Other, + Err(std::io::Error::other( child .stdout .map_or("Error in dot...".to_string(), |mut err| { @@ -449,9 +448,9 @@ impl Display for DotStateAttribute { f, "{}", match self { - DotStateAttribute::Label(s) => format!("label=\"{}\"", s), - DotStateAttribute::Shape(s) => format!("shape=\"{}\"", s), - DotStateAttribute::Color(c) => format!("color=\"{}\"", c), + Self::Label(s) => format!("label=\"{}\"", s), + Self::Shape(s) => format!("shape=\"{}\"", s), + Self::Color(c) => format!("color=\"{}\"", c), } ) } @@ -465,7 +464,7 @@ pub enum DotTransitionAttribute { impl Display for DotTransitionAttribute { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - DotTransitionAttribute::Label(lbl) => write!(f, "label=\"{lbl}\""), + Self::Label(lbl) => write!(f, "label=\"{lbl}\""), } } } diff --git a/crates/automata/src/hoa/input.rs b/crates/automata/src/hoa/input.rs index 71af7f3..d1a15af 100644 --- a/crates/automata/src/hoa/input.rs +++ b/crates/automata/src/hoa/input.rs @@ -19,7 +19,7 @@ pub struct IntoDeterministicHoaAutomatonStream { } impl IntoDeterministicHoaAutomatonStream { - pub fn new(read: R) -> IntoDeterministicHoaAutomatonStream { + pub fn new(read: R) -> Self { Self { base: HoaAutomatonStream::new(read), } @@ -235,8 +235,8 @@ impl TryFrom<&hoars::Header> for OmegaAcceptanceCondition { }); match value.acceptance_name() { - hoars::AcceptanceName::Buchi => Ok(OmegaAcceptanceCondition::Buchi), - hoars::AcceptanceName::Parity => Ok(OmegaAcceptanceCondition::Parity( + hoars::AcceptanceName::Buchi => Ok(Self::Buchi), + hoars::AcceptanceName::Parity => Ok(Self::Parity( 0, acceptance_sets.unwrap() as Int, )), diff --git a/crates/automata/src/hoa/output.rs b/crates/automata/src/hoa/output.rs index 1bb2cb1..827e301 100644 --- a/crates/automata/src/hoa/output.rs +++ b/crates/automata/src/hoa/output.rs @@ -80,7 +80,7 @@ pub trait WriteHoa: TransitionSystem + Pointed { impl OmegaAcceptanceCondition { pub fn write_hoa(&self, w: &mut W) -> Result { match self { - OmegaAcceptanceCondition::Parity(low, high) => { + Self::Parity(low, high) => { let zero_based_range = high - low + (low % 2); write!( w, @@ -90,7 +90,7 @@ impl OmegaAcceptanceCondition { build_parity_condition_hoa(*low, *high) ) } - OmegaAcceptanceCondition::Buchi => { + Self::Buchi => { write!(w, "acc-name: Buchi\nAcceptance: 1 Inf(0)\n") } _ => todo!("Can not yet deal with other acceptance types"), diff --git a/crates/automata/src/ts.rs b/crates/automata/src/ts.rs index 4ee5fde..334168f 100644 --- a/crates/automata/src/ts.rs +++ b/crates/automata/src/ts.rs @@ -755,7 +755,7 @@ pub trait IntoEdgeTuple { impl IntoEdgeTuple for EdgeTuple { #[inline(always)] - fn into_edge_tuple(self) -> EdgeTuple { + fn into_edge_tuple(self) -> Self { self } } diff --git a/crates/automata/src/ts/builder.rs b/crates/automata/src/ts/builder.rs index 72c7001..8de755b 100644 --- a/crates/automata/src/ts/builder.rs +++ b/crates/automata/src/ts/builder.rs @@ -37,7 +37,7 @@ pub struct TSBuilder { impl TSBuilder { /// Creates an empty instance of `Self`, where states are uncolored (have color [`Void`]) pub fn without_state_colors() -> Self { - TSBuilder { + Self { symbols: OrderedSet::default(), edges: vec![], default: Some(Void), @@ -48,7 +48,7 @@ impl TSBuilder { impl TSBuilder { /// Creates an empty instance of `Self`, where edges are uncolored (have color [`Void`]) pub fn without_edge_colors() -> Self { - TSBuilder { + Self { symbols: OrderedSet::default(), edges: vec![], default: None, diff --git a/crates/automata/src/ts/connected_components.rs b/crates/automata/src/ts/connected_components.rs index 71ddf9e..f19e115 100644 --- a/crates/automata/src/ts/connected_components.rs +++ b/crates/automata/src/ts/connected_components.rs @@ -224,7 +224,7 @@ impl<'a, Ts: TransitionSystem> SccDecomposition<'a, Ts> { /// Tests whether two SCC decompositions are isomorphic. This is done by checking whether each /// SCC in one decomposition has a matching SCC in the other decomposition. - pub fn equivalent(&self, other: &SccDecomposition<'a, Ts>) -> bool { + pub fn equivalent(&self, other: &Self) -> bool { for elem in self.dag.iter() { if !other.dag.iter().any(|other_elem| elem == other_elem) { trace!("found no scc matching {elem:?} in other"); diff --git a/crates/automata/src/ts/path.rs b/crates/automata/src/ts/path.rs index b5c4d02..34e61c4 100644 --- a/crates/automata/src/ts/path.rs +++ b/crates/automata/src/ts/path.rs @@ -133,7 +133,7 @@ impl Path { } /// Extends self with the given `other` path. - pub fn extend_with(&mut self, other: Path) { + pub fn extend_with(&mut self, other: Self) { assert_eq!(self.reached(), other.origin(), "Start and end must match!"); self.transitions.extend(other.transitions); self.state_colors @@ -175,12 +175,12 @@ impl Path { debug_assert!(self.end == self.transitions[position].0); Lasso::new( - Path::from_parts( + Self::from_parts( self.transitions[position].0, self.state_colors[..=position].to_vec(), self.transitions[..position].to_vec(), ), - Path::from_parts( + Self::from_parts( self.end, self.state_colors[position..].to_vec(), self.transitions[position..].to_vec(), diff --git a/crates/automata/src/ts/run.rs b/crates/automata/src/ts/run.rs index 22d2202..869d85d 100644 --- a/crates/automata/src/ts/run.rs +++ b/crates/automata/src/ts/run.rs @@ -132,7 +132,7 @@ impl>, const FINITE: bool, O: Obs impl<'ts, T: Deterministic, W: FiniteWord>, O: Observer> Run<'ts, T, W, true, O> { - pub fn new_finite(ts: &'ts T, start: StateIndex, word: W) -> Run<'ts, T, W, true, O> { + pub fn new_finite(ts: &'ts T, start: StateIndex, word: W) -> Self { Run { ts, start, @@ -163,7 +163,7 @@ impl<'ts, T: Deterministic, W: FiniteWord>, O: Observer> impl<'ts, T: Deterministic, W: OmegaWord>, O: InfiniteObserver> Run<'ts, T, W, false, O> { - pub fn new_infinite(ts: &'ts T, start: StateIndex, word: W) -> Run<'ts, T, W, false, O> { + pub fn new_infinite(ts: &'ts T, start: StateIndex, word: W) -> Self { Run { ts, start, @@ -359,27 +359,27 @@ impl>, O: Observer> FiniteR #[allow(unused)] fn escape_state(&self) -> Option> { match self { - FiniteRunOutput::Reached(_, _) => None, - FiniteRunOutput::Failed(state, _) => Some(*state), + Self::Reached(_, _) => None, + Self::Failed(state, _) => Some(*state), } } /// Returns the [`EscapePrefix`] with which the ts is left. #[allow(unused)] fn escape_prefix(&self) -> Option<&EscapePrefix> { match self { - FiniteRunOutput::Reached(_, _) => None, - FiniteRunOutput::Failed(_state, ep) => Some(ep), + Self::Reached(_, _) => None, + Self::Failed(_state, ep) => Some(ep), } } pub fn into_reached_state(self) -> Option> { match self { - FiniteRunOutput::Reached(r, _) => Some(r), + Self::Reached(r, _) => Some(r), _ => None, } } pub fn into_output(self) -> Option { match self { - FiniteRunOutput::Reached(_, o) => Some(o), + Self::Reached(_, o) => Some(o), _ => None, } } @@ -402,10 +402,10 @@ where { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - InfiniteRunOutput::Failed(q, esc) => { + Self::Failed(q, esc) => { write!(f, "failed from {q:?} with escape prefix {esc:?}") } - InfiniteRunOutput::Successful(ind) => write!(f, "successfully induced {ind:?}"), + Self::Successful(ind) => write!(f, "successfully induced {ind:?}"), } } } @@ -415,7 +415,7 @@ impl>, O: InfiniteObserve { #[inline(always)] pub fn is_successful(&self) -> bool { - matches!(self, InfiniteRunOutput::Successful(_)) + matches!(self, Self::Successful(_)) } #[inline(always)] pub fn is_escaping(&self) -> bool { @@ -460,7 +460,7 @@ mod impls { fn into_current(self) -> Self::Current {} #[inline(always)] fn begin(_ts: &T, _state: StateIndex) -> Self { - NoObserver + Self } #[inline(always)] fn observe_one( diff --git a/crates/hoars/src/body.rs b/crates/hoars/src/body.rs index 7048dec..29b432d 100644 --- a/crates/hoars/src/body.rs +++ b/crates/hoars/src/body.rs @@ -116,7 +116,7 @@ impl From<(Option, ExplicitEdge)> for Edge { AcceptanceSignature(left.iter().cloned().chain(right.iter().cloned()).collect()) } }; - Edge(edge.0, edge.1, acc) + Self(edge.0, edge.1, acc) } } @@ -135,7 +135,7 @@ impl TryFrom<(RawState, Vec)> for State { out_edges.push(Edge::from((state_acc.clone(), raw_edge))); } - Ok(State(id, state_text, out_edges)) + Ok(Self(id, state_text, out_edges)) } } @@ -209,7 +209,7 @@ impl Body { impl From> for Body { fn from(value: Vec) -> Self { - Body(value) + Self(value) } } diff --git a/crates/hoars/src/format.rs b/crates/hoars/src/format.rs index ef14534..9447dc8 100644 --- a/crates/hoars/src/format.rs +++ b/crates/hoars/src/format.rs @@ -55,7 +55,7 @@ impl AcceptanceSignature { /// Tries to get the singleton element of the acceptance signature, if it exists. /// Returns `None` if the acceptance signature is not a singleton. pub fn get_singleton(&self) -> Option> { - if self.len() == 0 { + if self.is_empty() { Some(None) } else if self.len() == 1 { Some(Some(self[0])) @@ -107,18 +107,18 @@ impl AcceptanceCondition { fn parity_rec(current: u32, total: u32) -> Self { if current + 1 >= total { if current.rem(2) == 0 { - AcceptanceCondition::id_inf(current) + Self::id_inf(current) } else { - AcceptanceCondition::id_fin(current) + Self::id_fin(current) } } else if current.rem(2) == 0 { - AcceptanceCondition::Or( - Box::new(AcceptanceCondition::Inf(AcceptanceAtom::Positive(current))), + Self::Or( + Box::new(Self::Inf(AcceptanceAtom::Positive(current))), Box::new(Self::parity_rec(current + 1, total)), ) } else { - AcceptanceCondition::And( - Box::new(AcceptanceCondition::Fin(AcceptanceAtom::Positive(current))), + Self::And( + Box::new(Self::Fin(AcceptanceAtom::Positive(current))), Box::new(Self::parity_rec(current + 1, total)), ) } @@ -131,22 +131,22 @@ impl AcceptanceCondition { /// Creates a Buchi acceptance condition. pub fn buchi() -> Self { - AcceptanceCondition::Inf(AcceptanceAtom::Positive(0)) + Self::Inf(AcceptanceAtom::Positive(0)) } /// Creates a conjunction of two acceptance conditions. - pub fn and>(&self, other: C) -> Self { - AcceptanceCondition::And(Box::new(self.clone()), Box::new(other.borrow().clone())) + pub fn and>(&self, other: C) -> Self { + Self::And(Box::new(self.clone()), Box::new(other.borrow().clone())) } /// Creates a disjunction of two acceptance conditions. - pub fn or>(&self, other: C) -> Self { - AcceptanceCondition::Or(Box::new(self.clone()), Box::new(other.borrow().clone())) + pub fn or>(&self, other: C) -> Self { + Self::Or(Box::new(self.clone()), Box::new(other.borrow().clone())) } /// Creates an acceptance condition containing the given atom. pub fn atom>(atom: A) -> Self { - AcceptanceCondition::Fin(atom.borrow().clone()) + Self::Fin(atom.borrow().clone()) } /// Creates an acceptance condition consisting of a positive atodm. @@ -210,7 +210,7 @@ pub enum AcceptanceName { impl AcceptanceName { pub fn is_parity(&self) -> bool { - matches!(self, AcceptanceName::Parity) + matches!(self, Self::Parity) } } @@ -219,16 +219,16 @@ impl TryFrom for AcceptanceName { fn try_from(value: String) -> Result { match value.as_str() { - "Buchi" => Ok(AcceptanceName::Buchi), - "generalized-Buchi" => Ok(AcceptanceName::GeneralizedBuchi), - "co-Buchi" => Ok(AcceptanceName::CoBuchi), - "generalized-co-Buchi" => Ok(AcceptanceName::GeneralizedCoBuchi), - "Streett" => Ok(AcceptanceName::Streett), - "Rabin" => Ok(AcceptanceName::Rabin), - "generalized-Rabin" => Ok(AcceptanceName::GeneralizedRabin), - "parity" => Ok(AcceptanceName::Parity), - "all" => Ok(AcceptanceName::All), - "none" => Ok(AcceptanceName::None), + "Buchi" => Ok(Self::Buchi), + "generalized-Buchi" => Ok(Self::GeneralizedBuchi), + "co-Buchi" => Ok(Self::CoBuchi), + "generalized-co-Buchi" => Ok(Self::GeneralizedCoBuchi), + "Streett" => Ok(Self::Streett), + "Rabin" => Ok(Self::Rabin), + "generalized-Rabin" => Ok(Self::GeneralizedRabin), + "parity" => Ok(Self::Parity), + "all" => Ok(Self::All), + "none" => Ok(Self::None), val => Err(format!("Unknown acceptance type: {}", val)), } } @@ -264,24 +264,24 @@ impl TryFrom for Property { fn try_from(value: String) -> Result { match value.as_str() { - "state-labels" => Ok(Property::StateLabels), - "trans-labels" => Ok(Property::TransLabels), - "implicit-labels" => Ok(Property::ImplicitLabels), - "explicit-labels" => Ok(Property::ExplicitLabels), - "state-acc" => Ok(Property::StateAcceptance), - "trans-acc" => Ok(Property::TransitionAcceptance), - "univ-branch" => Ok(Property::UniversalBranching), - "no-univ-branch" => Ok(Property::NoUniversalBranching), - "deterministic" => Ok(Property::Deterministic), - "complete" => Ok(Property::Complete), - "unambiguous" => Ok(Property::Unambiguous), - "stutter-invariant" => Ok(Property::StutterInvariant), - "weak" => Ok(Property::Weak), - "very-weak" => Ok(Property::VeryWeak), - "inherently-weak" => Ok(Property::InherentlyWeak), - "terminatl" => Ok(Property::Terminal), - "tight" => Ok(Property::Tight), - "colored" => Ok(Property::Colored), + "state-labels" => Ok(Self::StateLabels), + "trans-labels" => Ok(Self::TransLabels), + "implicit-labels" => Ok(Self::ImplicitLabels), + "explicit-labels" => Ok(Self::ExplicitLabels), + "state-acc" => Ok(Self::StateAcceptance), + "trans-acc" => Ok(Self::TransitionAcceptance), + "univ-branch" => Ok(Self::UniversalBranching), + "no-univ-branch" => Ok(Self::NoUniversalBranching), + "deterministic" => Ok(Self::Deterministic), + "complete" => Ok(Self::Complete), + "unambiguous" => Ok(Self::Unambiguous), + "stutter-invariant" => Ok(Self::StutterInvariant), + "weak" => Ok(Self::Weak), + "very-weak" => Ok(Self::VeryWeak), + "inherently-weak" => Ok(Self::InherentlyWeak), + "terminatl" => Ok(Self::Terminal), + "tight" => Ok(Self::Tight), + "colored" => Ok(Self::Colored), unknown => Err(format!("{} is not a valid property", unknown)), } } @@ -300,12 +300,12 @@ pub enum AcceptanceInfo { impl AcceptanceInfo { /// Creates an [`AcceptanceInfo`] from a [`Display`]able. pub fn identifier(id: D) -> Self { - AcceptanceInfo::Identifier(id.to_string()) + Self::Identifier(id.to_string()) } /// Creates an [`AcceptanceInfo`] from an [`Id`]. pub fn integer(id: Id) -> Self { - AcceptanceInfo::Int(id) + Self::Int(id) } } diff --git a/crates/hoars/src/header.rs b/crates/hoars/src/header.rs index b8dcb43..c4f73b0 100644 --- a/crates/hoars/src/header.rs +++ b/crates/hoars/src/header.rs @@ -39,7 +39,7 @@ pub enum HeaderItem { impl HeaderItem { pub fn count_states(&self) -> Option { - if let HeaderItem::States(i) = self { + if let Self::States(i) = self { Some(*i as usize) } else { None @@ -47,7 +47,7 @@ impl HeaderItem { } pub fn try_acceptance_name(&self) -> Option<(&AcceptanceName, &[AcceptanceInfo])> { - if let HeaderItem::AcceptanceName(x, y) = self { + if let Self::AcceptanceName(x, y) = self { Some((x, y)) } else { None @@ -55,7 +55,7 @@ impl HeaderItem { } pub fn count_acceptance_sets(&self) -> Option { - if let HeaderItem::Acceptance(n, _) = self { + if let Self::Acceptance(n, _) = self { Some(*n as usize) } else { None @@ -66,7 +66,7 @@ impl HeaderItem { impl HeaderItem { /// Creates a new version 1 header item. pub fn v1() -> Self { - HeaderItem::Version("v1".to_string()) + Self::Version("v1".to_string()) } } @@ -170,7 +170,7 @@ impl Header { .map(HeaderItem::Version); version .then(item().repeated()) - .map(|(version, headers)| Header(std::iter::once(version).chain(headers).collect())) + .map(|(version, headers)| Self(std::iter::once(version).chain(headers).collect())) } /// Constructs a new header from a vector of header items. diff --git a/crates/hoars/src/label.rs b/crates/hoars/src/label.rs index c1aaac0..97d5f60 100644 --- a/crates/hoars/src/label.rs +++ b/crates/hoars/src/label.rs @@ -31,8 +31,8 @@ pub(crate) enum Atomic { impl Atomic { pub(crate) fn to_value(&self, vars: &[BddVariable]) -> (BddVariable, bool) { match self { - Atomic::Positive(i) => (vars[*i as usize], true), - Atomic::Negative(i) => (vars[*i as usize], false), + Self::Positive(i) => (vars[*i as usize], true), + Self::Negative(i) => (vars[*i as usize], false), } } } @@ -40,9 +40,9 @@ impl Atomic { impl AbstractLabelExpression { pub(crate) fn try_atom(&self) -> Option { match self { - AbstractLabelExpression::Integer(i) => Some(Atomic::Positive(*i)), - AbstractLabelExpression::Negated(bx) => match **bx { - AbstractLabelExpression::Integer(i) => Some(Atomic::Negative(i)), + Self::Integer(i) => Some(Atomic::Positive(*i)), + Self::Negated(bx) => match **bx { + Self::Integer(i) => Some(Atomic::Negative(i)), _ => None, }, _ => None, @@ -60,19 +60,19 @@ impl AbstractLabelExpression { pub fn try_into_bdd(self, vs: &BddVariableSet, vars: &[BddVariable]) -> Result { match self { - AbstractLabelExpression::Boolean(b) => Ok(match b { + Self::Boolean(b) => Ok(match b { true => vs.mk_true(), false => vs.mk_false(), }), - AbstractLabelExpression::Integer(i) => { + Self::Integer(i) => { if i < vs.num_vars() { Ok(vs.mk_var(vars[i as usize])) } else { Err(format!("AP identifier {i} is too high")) } } - AbstractLabelExpression::Negated(e) => Ok(e.try_into_bdd(vs, vars)?.not()), - AbstractLabelExpression::Conjunction(cs) => { + Self::Negated(e) => Ok(e.try_into_bdd(vs, vars)?.not()), + Self::Conjunction(cs) => { if let Some(ints) = cs.iter().map(|c| c.try_atom()).collect::>>() { let valuation = BddPartialValuation::from_values( &ints.into_iter().map(|a| a.to_value(vars)).collect_vec(), @@ -84,7 +84,7 @@ impl AbstractLabelExpression { )) } } - AbstractLabelExpression::Disjunction(ds) => { + Self::Disjunction(ds) => { if let Some(ints) = ds.iter().map(|c| c.try_atom()).collect::>>() { let valuation = BddPartialValuation::from_values( &ints.into_iter().map(|a| a.to_value(vars)).collect_vec(), @@ -127,8 +127,8 @@ pub enum LabelExpression { impl LabelExpression { pub fn try_into_hoa_expression(self, num_aps: u8) -> Result { match self { - LabelExpression::Expression(b) => Ok(b), - LabelExpression::Abstract(b) => b.try_into_prop(num_aps), + Self::Expression(b) => Ok(b), + Self::Abstract(b) => b.try_into_prop(num_aps), } } } diff --git a/crates/hoars/src/lexer.rs b/crates/hoars/src/lexer.rs index e5d7753..5275e13 100644 --- a/crates/hoars/src/lexer.rs +++ b/crates/hoars/src/lexer.rs @@ -22,19 +22,19 @@ pub enum Token { impl std::fmt::Display for Token { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Token::Bool(b) => write!(f, "{}", b), - Token::Int(n) => write!(f, "{}", n), - Token::Text(txt) => write!(f, "{}", txt), - Token::Identifier(id) => write!(f, "{}", id), - Token::Alias(alias) => write!(f, "@{}", alias), - Token::Header(hdr) => write!(f, "{}:", hdr), - Token::Op(o) => write!(f, "{}", o), - Token::Paren(c) => write!(f, "{}", c), - Token::Fin => write!(f, "Fin"), - Token::Inf => write!(f, "Inf"), - Token::BodyEnd => write!(f, "--END--"), - Token::BodyStart => write!(f, "--BODY--"), - Token::Abort => write!(f, "--ABORT--"), + Self::Bool(b) => write!(f, "{}", b), + Self::Int(n) => write!(f, "{}", n), + Self::Text(txt) => write!(f, "{}", txt), + Self::Identifier(id) => write!(f, "{}", id), + Self::Alias(alias) => write!(f, "@{}", alias), + Self::Header(hdr) => write!(f, "{}:", hdr), + Self::Op(o) => write!(f, "{}", o), + Self::Paren(c) => write!(f, "{}", c), + Self::Fin => write!(f, "Fin"), + Self::Inf => write!(f, "Inf"), + Self::BodyEnd => write!(f, "--END--"), + Self::BodyStart => write!(f, "--BODY--"), + Self::Abort => write!(f, "--ABORT--"), } } } diff --git a/crates/hoars/src/lib.rs b/crates/hoars/src/lib.rs index ca11598..326f3a0 100644 --- a/crates/hoars/src/lib.rs +++ b/crates/hoars/src/lib.rs @@ -60,19 +60,19 @@ pub enum FromHoaError { impl Display for FromHoaError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - FromHoaError::UnsupportedVersion(version) => { + Self::UnsupportedVersion(version) => { write!(f, "Unsupported HOA version ({})", version) } - FromHoaError::UnsupportedAcceptanceCondition => { + Self::UnsupportedAcceptanceCondition => { write!(f, "Unsupported acceptance condition") } - FromHoaError::UnsupportedBody => write!(f, "Unsupported body"), - FromHoaError::ParseAcceptanceCondition(message) => { + Self::UnsupportedBody => write!(f, "Unsupported body"), + Self::ParseAcceptanceCondition(message) => { write!(f, "Could not parse acceptance condition: {}", message) } - FromHoaError::Abort => write!(f, "Abort token encountered"), - FromHoaError::LexerError(rep) => write!(f, "Lexer error: {}", rep), - FromHoaError::ParserError(rep) => write!(f, "Parser error: {}", rep), + Self::Abort => write!(f, "Abort token encountered"), + Self::LexerError(rep) => write!(f, "Lexer error: {}", rep), + Self::ParserError(rep) => write!(f, "Parser error: {}", rep), } } } @@ -132,7 +132,7 @@ impl HoaRepresentation { Header::parser() .then(Body::parser()) .then_ignore(end()) - .map(HoaRepresentation::from_parsed) + .map(Self::from_parsed) } /// Creates a new HOA automaton from the given version, header and @@ -284,7 +284,7 @@ impl HoaRepresentation { impl Default for HoaRepresentation { fn default() -> Self { - HoaRepresentation::from_parts(vec![HeaderItem::Version("v1".into())].into(), vec![].into()) + Self::from_parts(vec![HeaderItem::Version("v1".into())].into(), vec![].into()) } } @@ -299,15 +299,15 @@ impl TryFrom<&str> for HoaRepresentation { impl std::fmt::Display for AbstractLabelExpression { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - AbstractLabelExpression::Boolean(b) => match b { + Self::Boolean(b) => match b { true => write!(f, "t"), false => write!(f, "f"), }, - AbstractLabelExpression::Integer(i) => write!(f, "{i}"), - AbstractLabelExpression::Negated(expr) => { + Self::Integer(i) => write!(f, "{i}"), + Self::Negated(expr) => { write!(f, "!{}", expr) } - AbstractLabelExpression::Conjunction(conjuncts) => { + Self::Conjunction(conjuncts) => { let mut it = conjuncts.iter(); if let Some(first) = it.next() { Display::fmt(first, f)?; @@ -318,7 +318,7 @@ impl std::fmt::Display for AbstractLabelExpression { } Ok(()) } - AbstractLabelExpression::Disjunction(disjuncts) => { + Self::Disjunction(disjuncts) => { let mut it = disjuncts.iter(); if let Some(first) = it.next() { Display::fmt(first, f)?; diff --git a/crates/hoars/src/output.rs b/crates/hoars/src/output.rs index e0a0fcf..a03ceaa 100644 --- a/crates/hoars/src/output.rs +++ b/crates/hoars/src/output.rs @@ -21,29 +21,29 @@ pub fn to_hoa(aut: &HoaRepresentation) -> String { impl Display for HeaderItem { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - HeaderItem::Version(version) => write!(f, "HOA: {}", version), - HeaderItem::States(number) => write!(f, "States: {}", number), - HeaderItem::Start(state_conj) => write!(f, "Start: {}", state_conj), - HeaderItem::AP(aps) => write!( + Self::Version(version) => write!(f, "HOA: {}", version), + Self::States(number) => write!(f, "States: {}", number), + Self::Start(state_conj) => write!(f, "Start: {}", state_conj), + Self::AP(aps) => write!( f, "AP: {} {}", aps.len(), aps.iter().map(|ap| format!("\"{}\"", ap)).join(" ") ), - HeaderItem::Alias(alias_name, alias_expression) => { + Self::Alias(alias_name, alias_expression) => { write!(f, "Alias: {} {}", alias_name, alias_expression) } - HeaderItem::Acceptance(number_sets, condition) => { + Self::Acceptance(number_sets, condition) => { write!(f, "Acceptance: {} {}", number_sets, condition) } - HeaderItem::AcceptanceName(identifier, vec_info) => { + Self::AcceptanceName(identifier, vec_info) => { write!(f, "acc-name: {} {}", identifier, vec_info.iter().join(" ")) } - HeaderItem::Tool(name, options) => { + Self::Tool(name, options) => { write!(f, "tool: {} {}", name, options.iter().join(" ")) } - HeaderItem::Name(name) => write!(f, "name: {}", name), - HeaderItem::Properties(properties) => { + Self::Name(name) => write!(f, "name: {}", name), + Self::Properties(properties) => { write!(f, "properties: {}", properties.iter().join(" ")) } } @@ -53,8 +53,8 @@ impl Display for HeaderItem { impl Display for AcceptanceInfo { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - AcceptanceInfo::Int(integer) => write!(f, "{}", integer), - AcceptanceInfo::Identifier(identifier) => write!(f, "{}", identifier), + Self::Int(integer) => write!(f, "{}", integer), + Self::Identifier(identifier) => write!(f, "{}", identifier), } } } @@ -65,24 +65,24 @@ impl Display for Property { f, "{}", match self { - Property::StateLabels => "state-labels", - Property::TransLabels => "trans-labels", - Property::ImplicitLabels => "implicit-labels", - Property::ExplicitLabels => "explicit-labels", - Property::StateAcceptance => "state-acc", - Property::TransitionAcceptance => "trans-acc", - Property::UniversalBranching => "univ-branch", - Property::NoUniversalBranching => "no-univ-branch", - Property::Deterministic => "deterministic", - Property::Complete => "complete", - Property::Unambiguous => "unabmiguous", - Property::StutterInvariant => "stutter-invariant", - Property::Weak => "weak", - Property::VeryWeak => "very-weak", - Property::InherentlyWeak => "inherently-weak", - Property::Terminal => "terminal", - Property::Tight => "tight", - Property::Colored => "colored", + Self::StateLabels => "state-labels", + Self::TransLabels => "trans-labels", + Self::ImplicitLabels => "implicit-labels", + Self::ExplicitLabels => "explicit-labels", + Self::StateAcceptance => "state-acc", + Self::TransitionAcceptance => "trans-acc", + Self::UniversalBranching => "univ-branch", + Self::NoUniversalBranching => "no-univ-branch", + Self::Deterministic => "deterministic", + Self::Complete => "complete", + Self::Unambiguous => "unabmiguous", + Self::StutterInvariant => "stutter-invariant", + Self::Weak => "weak", + Self::VeryWeak => "very-weak", + Self::InherentlyWeak => "inherently-weak", + Self::Terminal => "terminal", + Self::Tight => "tight", + Self::Colored => "colored", } ) } @@ -94,16 +94,16 @@ impl Display for AcceptanceName { f, "{}", match self { - AcceptanceName::Buchi => "Buchi", - AcceptanceName::GeneralizedBuchi => "generalized-Buchi", - AcceptanceName::CoBuchi => "co-Buchi", - AcceptanceName::GeneralizedCoBuchi => "generalized-co-Buchi", - AcceptanceName::Streett => "Streett", - AcceptanceName::Rabin => "Rabin", - AcceptanceName::GeneralizedRabin => "generalized-Rabin", - AcceptanceName::Parity => "parity", - AcceptanceName::All => "all", - AcceptanceName::None => "none", + Self::Buchi => "Buchi", + Self::GeneralizedBuchi => "generalized-Buchi", + Self::CoBuchi => "co-Buchi", + Self::GeneralizedCoBuchi => "generalized-co-Buchi", + Self::Streett => "Streett", + Self::Rabin => "Rabin", + Self::GeneralizedRabin => "generalized-Rabin", + Self::Parity => "parity", + Self::All => "all", + Self::None => "none", } ) } @@ -112,8 +112,8 @@ impl Display for AcceptanceName { impl Display for AcceptanceAtom { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - AcceptanceAtom::Positive(id) => write!(f, "{}", id), - AcceptanceAtom::Negative(id) => write!(f, "!{}", id), + Self::Positive(id) => write!(f, "{}", id), + Self::Negative(id) => write!(f, "!{}", id), } } } @@ -127,11 +127,11 @@ impl Display for HoaBool { impl Display for AcceptanceCondition { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - AcceptanceCondition::Fin(id) => write!(f, "Fin({})", id), - AcceptanceCondition::Inf(id) => write!(f, "Inf({})", id), - AcceptanceCondition::And(left, right) => write!(f, "({} & {})", left, right), - AcceptanceCondition::Or(left, right) => write!(f, "({} | {})", left, right), - AcceptanceCondition::Boolean(val) => write!(f, "{}", val), + Self::Fin(id) => write!(f, "Fin({})", id), + Self::Inf(id) => write!(f, "Inf({})", id), + Self::And(left, right) => write!(f, "({} & {})", left, right), + Self::Or(left, right) => write!(f, "({} | {})", left, right), + Self::Boolean(val) => write!(f, "{}", val), } } } From ba348c604cd8c3a5e0206f161a97436a7f19712d Mon Sep 17 00:00:00 2001 From: adamnemecek Date: Sat, 3 May 2025 17:03:18 -0700 Subject: [PATCH 2/2] cargo fmt --- crates/automata/src/automaton.rs | 14 +++----------- crates/automata/src/automaton/omega.rs | 6 +----- crates/automata/src/dot.rs | 21 ++++++++++----------- crates/automata/src/hoa/input.rs | 5 +---- 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/crates/automata/src/automaton.rs b/crates/automata/src/automaton.rs index 5cdeb9c..b36aa05 100644 --- a/crates/automata/src/automaton.rs +++ b/crates/automata/src/automaton.rs @@ -113,10 +113,7 @@ where /// dfa.add_edge((0, 'b', 0)); /// assert!(!dfa.accepts("bbabababbabbba")); /// ``` - pub fn new_with_initial_color( - alphabet: A, - initial_color: Q, - ) -> Self + pub fn new_with_initial_color(alphabet: A, initial_color: Q) -> Self where D: ForAlphabet + Sproutable, Z: Default, @@ -129,11 +126,7 @@ where /// Uses `Self::new_with_initial_color` to create a new instance of /// `Self` and then makes all transitions self-loops emitting the given /// color. - pub fn new_trivial_with_initial_color( - alphabet: A, - initial_color: Q, - edge_color: C, - ) -> Self + pub fn new_trivial_with_initial_color(alphabet: A, initial_color: Q, edge_color: C) -> Self where D: ForAlphabet + Sproutable, Z: Default, @@ -276,8 +269,7 @@ where } } -impl AsRef - for Automaton +impl AsRef for Automaton where A: Alphabet, D: TransitionSystem, diff --git a/crates/automata/src/automaton/omega.rs b/crates/automata/src/automaton/omega.rs index cc723f8..4564e5f 100644 --- a/crates/automata/src/automaton/omega.rs +++ b/crates/automata/src/automaton/omega.rs @@ -214,10 +214,6 @@ impl TryFrom> } assert!(value.initial().into_usize() < size); - Ok(Self::new( - ts, - value.initial, - value.acceptance, - )) + Ok(Self::new(ts, value.initial, value.acceptance)) } } diff --git a/crates/automata/src/dot.rs b/crates/automata/src/dot.rs index 3a56be1..ace75ff 100644 --- a/crates/automata/src/dot.rs +++ b/crates/automata/src/dot.rs @@ -216,17 +216,16 @@ pub trait Dottable: TransitionSystem { .arg(tempfile_name) .spawn()?; if !child.wait()?.success() { - Err(std::io::Error::other( - child - .stdout - .map_or("Error in dot...".to_string(), |mut err| { - let mut buf = String::new(); - if let Err(e) = err.read_to_string(&mut buf) { - buf = format!("Could not read from stdout: {e}"); - } - buf - }), - )) + Err(std::io::Error::other(child.stdout.map_or( + "Error in dot...".to_string(), + |mut err| { + let mut buf = String::new(); + if let Err(e) = err.read_to_string(&mut buf) { + buf = format!("Could not read from stdout: {e}"); + } + buf + }, + ))) } else { Ok(()) } diff --git a/crates/automata/src/hoa/input.rs b/crates/automata/src/hoa/input.rs index d1a15af..354896e 100644 --- a/crates/automata/src/hoa/input.rs +++ b/crates/automata/src/hoa/input.rs @@ -236,10 +236,7 @@ impl TryFrom<&hoars::Header> for OmegaAcceptanceCondition { match value.acceptance_name() { hoars::AcceptanceName::Buchi => Ok(Self::Buchi), - hoars::AcceptanceName::Parity => Ok(Self::Parity( - 0, - acceptance_sets.unwrap() as Int, - )), + hoars::AcceptanceName::Parity => Ok(Self::Parity(0, acceptance_sets.unwrap() as Int)), _ => Err("Unsupported acceptance condition".to_string()), } }