Skip to content

Commit

Permalink
REFACTOR Clippy and style changes for Rust 1.37.
Browse files Browse the repository at this point in the history
  • Loading branch information
elfsternberg committed Aug 20, 2019
1 parent e8f33dd commit e563ed0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/board.rs
Expand Up @@ -90,7 +90,7 @@ fn innersolveforpos(
skip_pos_check: bool,
) {
match curr.add(c, (x, y), skip_pos_check) {
None => return,
None => (),
Some(mut newcurr) => {
if newcurr.0.len() > 2 && board.words.find(&mut newcurr.0.chars()) {
solutions.push(newcurr.0.to_string());
Expand Down
9 changes: 2 additions & 7 deletions src/solve_threaded.rs
Expand Up @@ -55,13 +55,8 @@ pub fn solve_mt(board: &Board, threads: usize) -> Vec<String> {
spawner.spawn(move |_| {
let mut solutions: Vec<String> = vec![];
let mut queue: Worker<Job> = Worker::new_fifo();
loop {
match find_task(&mut queue, &work) {
Some(mut job) => {
solveforpos(&board, (job.0, job.1), &mut job.2, &mut solutions);
}
None => break,
}
while let Some(mut job) = find_task(&mut queue, &work) {
solveforpos(&board, (job.0, job.1), &mut job.2, &mut solutions);
}
solutions
})
Expand Down
8 changes: 4 additions & 4 deletions src/trie.rs
Expand Up @@ -48,7 +48,7 @@ where
/// nodes with the rest of the iterator after processing the
/// letter given. If there is no letter, this node is marked as a
/// terminator ("yes, that is a word") and processing ends.
pub fn insert(&mut self, word: &mut Iterator<Item = C>) {
pub fn insert(&mut self, word: &mut dyn Iterator<Item = C>) {
let c = match word.next() {
None => {
self.1 = true;
Expand All @@ -75,7 +75,7 @@ where
/// node a word node?" But for pref(), which only tells you if
/// the prefix xists, the endstate is "does this node exist at
/// all?"
fn search(&self, word: &mut Iterator<Item = C>, endstate: &Fn(&Node<C>) -> bool) -> bool {
fn search(&self, word: &mut dyn Iterator<Item = C>, endstate: &dyn Fn(&Node<C>) -> bool) -> bool {
let c = match word.next() {
None => return endstate(self),
Some(c) => c,
Expand All @@ -95,14 +95,14 @@ where
/// says "if, when you're out of letters in the sample string,
/// the node you're on has its bool set to true, it is a whole
/// word found in the dictionary."
pub fn find(&self, word: &mut Iterator<Item = C>) -> bool {
pub fn find(&self, word: &mut dyn Iterator<Item = C>) -> bool {
self.search(word, &|s| s.1)
}

/// Determine if the word is in the trie, or is the prefix of a word
/// in the trie. All that matters here is that we're still in the
/// trie when we run out of letters.
pub fn pref(&self, word: &mut Iterator<Item = C>) -> bool {
pub fn pref(&self, word: &mut dyn Iterator<Item = C>) -> bool {
self.search(word, &|_s| true)
}
}
Expand Down

0 comments on commit e563ed0

Please sign in to comment.