Teacup rim text: Difference between revisions
m
Rust - use containers of references in find_teacup_words to avoid unnecessary copying
m (Rust - reformatted with rustfmt) |
m (Rust - use containers of references in find_teacup_words to avoid unnecessary copying) |
||
Line 1,533:
let mut dict = BTreeSet::new();
for line in io::BufReader::new(file).lines() {
}▼
}
Ok(dict)
Line 1,541 ⟶ 1,540:
fn find_teacup_words(dict: &BTreeSet<String>) {
let mut teacup_words: Vec<&String> = Vec::new();
let mut found: HashSet<&String> = HashSet::new();
for word in dict {
let len = word.len();
Line 1,553 ⟶ 1,552:
for _ in 1..len {
chars.rotate_left(1);
}
is_teacup_word = false;
break;
▲ }
}
}
Line 1,566 ⟶ 1,568:
}
print!("{}", word);
found.insert(word
for w in &teacup_words {
found.insert(w
print!(" {}", w);
}
|