Skip to content

Commit

Permalink
style: clippy (the old version used on pipeline)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukáš Chudíček committed Dec 17, 2023
1 parent 32c2acd commit 77e735a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 52 deletions.
4 changes: 1 addition & 3 deletions src/prototype/smart_system_update_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<D: SymbolicDomain<u8>> SmartSystemUpdateFn<D, u8> {
),
);

let primed_name = format!("{}'", name.clone());
let primed_name = format!("{}'", name);
let primed = (
primed_name.clone(),
D::new(
Expand Down Expand Up @@ -2247,7 +2247,6 @@ mod tests {
// the orderings might be fcked up -> pair the corresponding bdds of the two
let smart_triple_sorted = {
let mut smart_triple_sorted = smart_triple
.clone()
.into_iter()
.map(|(name, val, bdd)| (format!("{}-{}", name, val), bdd))
.collect::<Vec<_>>();
Expand All @@ -2258,7 +2257,6 @@ mod tests {

let force_triple_sorted = {
let mut force_triple_sorted = force_triple
.clone()
.into_iter()
.map(|(name, val, bdd)| (format!("{}-{}", name, val), bdd))
.collect::<Vec<_>>();
Expand Down
12 changes: 2 additions & 10 deletions src/prototype/symbolic_domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,7 @@ impl SymbolicDomain<u8> for BinaryIntegerDomain<u8> {
.iter()
.enumerate()
.fold(0, |acc, (idx, var)| {
let bit = if bdd_valuation.get_value(*var).unwrap() {
1
} else {
0
};
let bit = u8::from(bdd_valuation.get_value(*var).unwrap());

acc | (bit << idx)
});
Expand Down Expand Up @@ -561,11 +557,7 @@ impl SymbolicDomain<u8> for GrayCodeIntegerDomain<u8> {
.iter()
.enumerate()
.fold(0, |acc, (idx, var)| {
let bit = if bdd_valuation.get_value(*var).unwrap() {
1
} else {
0
};
let bit = u8::from(bdd_valuation.get_value(*var).unwrap());

acc | (bit << idx)
});
Expand Down
13 changes: 5 additions & 8 deletions src/prototype/system_update_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl<D: SymbolicDomain<u8>> SystemUpdateFn<D, u8> {
let unnormalized_res = domain
.get_all_possible_values(&self.bdd_variable_set)
.into_iter()
.fold(const_false.clone(), |acc, possible_var_val| {
.fold(const_false, |acc, possible_var_val| {
let bits_of_the_encoded_value = domain.encode_bits_into_vec(possible_var_val);

// println!("{:?}", bits_of_the_encoded_value);
Expand Down Expand Up @@ -430,13 +430,11 @@ impl<D: SymbolicDomain<u8>> SystemUpdateFn<D, u8> {
.collect::<Vec<_>>();

// must order the bit-answering bdds the way the variables are ordered in the domain
let correctly_ordered_bit_answered_bdds = vars_and_their_bits
.iter()
.map(|(bdd_variable, _)| {
let correctly_ordered_bit_answered_bdds =
vars_and_their_bits.iter().map(|(bdd_variable, _)| {
vars_and_their_updating_bdds.get(bdd_variable).unwrap()
// todo here
})
.collect::<Vec<_>>();
});

// todo abstract the function `set_of_those_states_that_transition_to_specific_value_of_specific_variable`
// let those_transitioning_to_target =
Expand Down Expand Up @@ -517,7 +515,6 @@ impl<D: SymbolicDomain<u8>> SystemUpdateFn<D, u8> {
sym_dom.get_all_possible_values(&self.bdd_variable_set);

let all_possible_values_and_their_bits = all_possible_values_of_target_var
.clone()
.into_iter()
.map(|val| (val, sym_dom.encode_bits_into_vec(val)))
.collect::<Vec<_>>();
Expand Down Expand Up @@ -628,7 +625,7 @@ impl<D: SymbolicDomain<u8>> SystemUpdateFn<D, u8> {
sym_dom
.get_all_possible_values(&self.bdd_variable_set)
.into_iter()
.fold(const_false.clone(), |_acc, one_of_possible_values| {
.fold(const_false, |_acc, one_of_possible_values| {
let bits = sym_dom.encode_bits_into_vec(one_of_possible_values);
let target_set_of_states_with_known_value_of_target_var = target_set_of_states
.select(
Expand Down
12 changes: 6 additions & 6 deletions src/prototype/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,12 @@ impl<BR: BufRead> XmlReader<BR> for DebuggingReader<BR> {

if self.expecting_variable_value {
self.expecting_variable_value = false;
let actual_value = content.clone().trim().parse::<u8>().unwrap_or_else(
|_| panic!(
"currently only allowing DebugReader parse u8 values; got {}",
content
let actual_value = content.trim().parse::<u8>().unwrap_or_else(|_| {
panic!(
"currently only allowing DebugReader parse u8 values; got {}",
content
)
);
});

let associated_max_value = self.vars_and_their_max_values.get(
&self
Expand Down Expand Up @@ -427,7 +427,7 @@ impl<BR: BufRead> XmlReader<BR> for CountingReader<BR> {
fn next(&mut self) -> Result<XmlEvent, String> {
match self.xml.next() {
Ok(e) => {
match e.clone() {
match e {
XmlEvent::StartElement { .. } => {
self.curr_line += 1;
}
Expand Down
26 changes: 10 additions & 16 deletions src/symbolic_domains/symbolic_domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,11 @@ impl SymbolicDomain<u8> for BinaryIntegerDomain<u8> {
.iter()
.enumerate()
.fold(0, |acc, (idx, var)| {
let bit = if bdd_valuation
.get_value(*var)
.expect("bits of the value should be in the valuation")
{
1
} else {
0
};
let bit = u8::from(
bdd_valuation
.get_value(*var)
.expect("bits of the value should be in the valuation"),
);

acc | (bit << idx)
});
Expand Down Expand Up @@ -536,14 +533,11 @@ impl SymbolicDomain<u8> for GrayCodeIntegerDomain<u8> {
.iter()
.enumerate()
.fold(0, |acc, (idx, var)| {
let bit = if bdd_valuation
.get_value(*var)
.expect("bits of the value should be in the valuation")
{
1
} else {
0
};
let bit = u8::from(
bdd_valuation
.get_value(*var)
.expect("bits of the value should be in the valuation"),
);

acc | (bit << idx)
});
Expand Down
6 changes: 1 addition & 5 deletions src/xml_parsing/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,7 @@ where
namespace,
} => {
return if name.local_name == expected {
Ok(StartElementWrapper::new(
name,
attributes,
namespace.clone(),
))
Ok(StartElementWrapper::new(name, attributes, namespace))
} else {
Err(XmlReadingError::UnexpectedEvent {
expected: ExpectedXmlEvent::Start(expected.to_string()),
Expand Down
6 changes: 2 additions & 4 deletions src/xml_parsing/variable_update_fn_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ fn process_input_var_name_item<XR: XmlReader<BR>, BR: BufRead>(

let item = qualitative_species
.next()
.ok_or(XmlReadingError::NoSuchAttribute(
"qualitativeSpecies".to_string(),
))?; // todo
.ok_or_else(|| XmlReadingError::NoSuchAttribute("qualitativeSpecies".to_string()))?; // todo

expect_closure_of(xml, "input")?;

Expand Down Expand Up @@ -176,7 +174,7 @@ fn result_level_from_attributes<T: FromStr>(
.attributes
.iter()
.find(|attr_name| attr_name.name.local_name == "resultLevel")
.ok_or(XmlReadingError::NoSuchAttribute("resultLevel".to_string()))?;
.ok_or_else(|| XmlReadingError::NoSuchAttribute("resultLevel".to_string()))?;

attribute_with_result_lvl
.value
Expand Down

0 comments on commit 77e735a

Please sign in to comment.