Skip to content

Commit

Permalink
Clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonrhansen committed Aug 25, 2023
1 parent 2b5ef0a commit ac2d210
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 45 deletions.
36 changes: 6 additions & 30 deletions src/genetic/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,11 @@ mod tests {
fn basic_algorithm_test() {
let towards = 10.0;
let test_vec = vec![
TendUnit {
x: 0.3,
towards: towards,
},
TendUnit {
x: 0.1,
towards: towards,
},
TendUnit {
x: 0.7,
towards: towards,
},
TendUnit {
x: 2.3,
towards: towards,
},
TendUnit {
x: 4.3,
towards: towards,
},
TendUnit { x: 0.3, towards },
TendUnit { x: 0.1, towards },
TendUnit { x: 0.7, towards },
TendUnit { x: 2.3, towards },
TendUnit { x: 4.3, towards },
];

let best_unit = Population::new(test_vec.clone())
Expand All @@ -143,16 +128,7 @@ mod tests {
#[test]
fn no_survivors_test() {
let towards = 10.0;
let test_vec = vec![
TendUnit {
x: 0.3,
towards: towards,
},
TendUnit {
x: 0.7,
towards: towards,
},
];
let test_vec = vec![TendUnit { x: 0.3, towards }, TendUnit { x: 0.7, towards }];

let best_unit = Population::new(test_vec.clone())
.set_size(100)
Expand Down
2 changes: 1 addition & 1 deletion src/guillotine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,6 @@ mod tests {

stock_pieces
.iter()
.for_each(|stock_piece| assert!(!bin.matches_stock_piece(&stock_piece)))
.for_each(|stock_piece| assert!(!bin.matches_stock_piece(stock_piece)))
}
}
9 changes: 2 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ use serde::{Deserialize, Serialize};
/// Indicates the linear direction of a pattern, grain, etc.
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, Default, Hash, PartialEq, Eq)]
pub enum PatternDirection {
/// No pattern
#[default]
None,

/// Linear pattern that runs parallel to the width
Expand All @@ -52,12 +53,6 @@ impl PatternDirection {
}
}

impl Default for PatternDirection {
fn default() -> Self {
PatternDirection::None
}
}

/// A rectangular piece that needs to be cut from a stock piece.
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
Expand Down
2 changes: 1 addition & 1 deletion src/maxrects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,6 @@ mod tests {

stock_pieces
.iter()
.for_each(|stock_piece| assert!(!bin.matches_stock_piece(&stock_piece)))
.for_each(|stock_piece| assert!(!bin.matches_stock_piece(stock_piece)))
}
}
12 changes: 6 additions & 6 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ fn sanity_check_solution(solution: &Solution, num_cut_pieces: usize) {
#[test]
fn guillotine() {
let solution = Optimizer::new()
.add_stock_pieces(STOCK_PIECES.iter().cloned().collect::<Vec<_>>())
.add_cut_pieces(CUT_PIECES.iter().cloned().collect::<Vec<_>>())
.add_stock_pieces(STOCK_PIECES.to_vec())
.add_cut_pieces(CUT_PIECES.to_vec())
.set_cut_width(1)
.set_random_seed(1)
.optimize_guillotine(|_| {})
Expand Down Expand Up @@ -316,7 +316,7 @@ fn guillotine_non_fitting_cut_piece_mismatched_pattern() {
#[test]
fn guillotine_no_allow_mixed_stock_sizes() {
let solution = Optimizer::new()
.add_stock_pieces(STOCK_PIECES.iter().cloned().collect::<Vec<_>>())
.add_stock_pieces(STOCK_PIECES.to_vec())
.add_cut_piece(CutPiece {
quantity: 1,
external_id: Some(1),
Expand Down Expand Up @@ -851,8 +851,8 @@ fn guillotine_random_cut_pieces() {
#[test]
fn nested() {
let solution = Optimizer::new()
.add_stock_pieces(STOCK_PIECES.iter().cloned().collect::<Vec<_>>())
.add_cut_pieces(CUT_PIECES.iter().cloned().collect::<Vec<_>>())
.add_stock_pieces(STOCK_PIECES.to_vec())
.add_cut_pieces(CUT_PIECES.to_vec())
.set_cut_width(1)
.set_random_seed(1)
.optimize_nested(|_| {})
Expand Down Expand Up @@ -1067,7 +1067,7 @@ fn nested_non_fitting_cut_piece_mismatched_pattern() {
#[test]
fn nested_no_allow_mixed_stock_sizes() {
let solution = Optimizer::new()
.add_stock_pieces(STOCK_PIECES.iter().cloned().collect::<Vec<_>>())
.add_stock_pieces(STOCK_PIECES.to_vec())
.add_cut_piece(CutPiece {
quantity: 1,
external_id: Some(1),
Expand Down

0 comments on commit ac2d210

Please sign in to comment.