Skip to content

Commit

Permalink
code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
rfuzzo committed Dec 8, 2023
1 parent cd254f9 commit 1547991
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
16 changes: 9 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ where
// rule parsing
if parsing && line.is_empty() {
parsing = false;
if current_rule.is_some() {
match current_rule.as_ref().unwrap() {
if let Some(current_rule) = &current_rule {
match current_rule {
RuleKind::Order => {
orders.push(current_order.to_owned());
current_order.clear();
Expand All @@ -288,11 +288,13 @@ where
}

// finish rule parsing
if parsing && current_rule.is_some() {
match current_rule.as_ref().unwrap() {
RuleKind::Order => current_order.push(line),
RuleKind::Note => todo!(),
RuleKind::Conflict => todo!(),
if parsing {
if let Some(current_rule) = &current_rule {
match current_rule {
RuleKind::Order => current_order.push(line),
RuleKind::Note => todo!(),
RuleKind::Conflict => todo!(),
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_expression_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod unit_expressions_tests {

#[test]
fn evaluate_all() {
let mods: Vec<String> = vec!["a", "b", "c", "d", "e", "f", "g"]
let mods: Vec<String> = ["a", "b", "c", "d", "e", "f", "g"]
.iter()
.map(|e| (*e).into())
.collect();
Expand All @@ -24,7 +24,7 @@ mod unit_expressions_tests {

#[test]
fn evaluate_any() {
let mods: Vec<String> = vec!["a", "b", "c", "d", "e", "f", "g"]
let mods: Vec<String> = ["a", "b", "c", "d", "e", "f", "g"]
.iter()
.map(|e| (*e).into())
.collect();
Expand All @@ -44,7 +44,7 @@ mod unit_expressions_tests {

#[test]
fn evaluate_not() {
let mods: Vec<String> = vec!["a", "b", "c", "d", "e", "f", "g"]
let mods: Vec<String> = ["a", "b", "c", "d", "e", "f", "g"]
.iter()
.map(|e| (*e).into())
.collect();
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_rules_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ mod unit_rules_tests {

#[test]
fn test_notes() {
let mods: Vec<String> = vec!["a", "b", "c", "d", "e", "f", "g"]
let mods: Vec<String> = ["a", "b", "c", "d", "e", "f", "g"]
.iter()
.map(|e| (*e).into())
.collect();

let rules: Vec<_> = vec![("a", "some a"), ("c", "some b"), ("x", "some x!")]
let rules: Vec<_> = [("a", "some a"), ("c", "some b"), ("x", "some x!")]
.iter()
.map(|e| Note {
comment: e.1.into(),
Expand All @@ -29,7 +29,7 @@ mod unit_rules_tests {

#[test]
fn test_conflicts() {
let mods: Vec<String> = vec!["a", "b", "c", "d", "e", "f", "g"]
let mods: Vec<String> = ["a", "b", "c", "d", "e", "f", "g"]
.iter()
.map(|e| (*e).into())
.collect();
Expand Down
14 changes: 7 additions & 7 deletions tests/unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ mod unit_tests {
#[test]
fn test_cycle() {
let rules = Rules {
order: vec![("a", "b"), ("b", "c"), ("d", "e"), ("b", "a")]
order: [("a", "b"), ("b", "c"), ("d", "e"), ("b", "a")]
.iter()
.map(|e| (e.0.to_owned(), e.1.to_owned()))
.collect(),
};

let mods: Vec<String> = vec!["a", "b", "c", "d", "e", "f", "g"]
let mods: Vec<String> = ["a", "b", "c", "d", "e", "f", "g"]
.iter()
.map(|e| (*e).into())
.collect();
Expand All @@ -25,7 +25,7 @@ mod unit_tests {
#[test]
fn test_ordering() {
let rules = Rules {
order: vec![
order: [
("a", "b"),
("b", "c"),
("d", "e"),
Expand All @@ -37,7 +37,7 @@ mod unit_tests {
.collect(),
};

let mods = vec!["a", "b", "c", "d", "e", "f", "g"]
let mods = ["a", "b", "c", "d", "e", "f", "g"]
.iter()
.map(|e| (*e).into())
.collect();
Expand Down Expand Up @@ -70,12 +70,12 @@ mod unit_tests {

#[test]
fn test_notes() {
let mods: Vec<String> = vec!["a", "b", "c", "d", "e", "f", "g"]
let mods: Vec<String> = ["a", "b", "c", "d", "e", "f", "g"]
.iter()
.map(|e| (*e).into())
.collect();

let rules: Vec<_> = vec![("a", "some a"), ("c", "some b"), ("x", "some x!")]
let rules: Vec<_> = [("a", "some a"), ("c", "some b"), ("x", "some x!")]
.iter()
.map(|e| Note {
comment: e.1.into(),
Expand All @@ -95,7 +95,7 @@ mod unit_tests {

#[test]
fn test_conflicts() {
let mods: Vec<String> = vec!["a", "b", "c", "d", "e", "f", "g"]
let mods: Vec<String> = ["a", "b", "c", "d", "e", "f", "g"]
.iter()
.map(|e| (*e).into())
.collect();
Expand Down

0 comments on commit 1547991

Please sign in to comment.