Teacup rim text: Difference between revisions
m
Rust - reformatted with rustfmt
m (Rust - reformatted with rustfmt) |
|||
Line 1,529:
use std::iter::FromIterator;
fn load_dictionary(filename
let file = File::open(filename)?;
let mut dict = BTreeSet::new();
Line 1,540:
}
fn find_teacup_words(dict
let mut teacup_words
let mut found
for word in dict {
let len = word.len();
Line 1,550:
teacup_words.clear();
let mut is_teacup_word = true;
let mut chars
for _ in 1..len {
chars.rotate_left(1);
Line 1,576:
fn main() {
let args
if args.len() != 2 {
eprintln!("Usage: teacup dictionary");
Line 1,584:
match dict {
Ok(dict) => find_teacup_words(&dict),
Err(error) => eprintln!("Cannot open file {}: {}", &args[1], error),
}
}</lang>
|