Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
use std::fs::File;
use std::path::Path;
use std::error::Error;
use std::io::{BufRead, BufReader, stdin};
use std::collections::HashMap;
fn sort_str(s: &str) -> String {
let mut v: Vec<char> = s.chars().collect();
fn main() {
let path = Path::new("../word.lst");
let file = match File::open(&path) {
Err(why) => panic!("failed to open {}: {}", path.display(),
Ok(f) => f,
let mut dict: HashMap<String, Vec<String>> = HashMap::new();
for line in BufReader::new(file).lines() {
let s = line.unwrap();
let sin = stdin();
for line in sin.lock().lines() {
let s = line.unwrap();
if let Some(v) = dict.get(&sort_str(&s)) {
println!("anagrams for {}: {}", &s, &v.connect(" "));
} else {
println!("no dice");

This comment has been minimized.

Copy link
Owner Author

commented Sep 18, 2015

Rust compiler v 1.3.0 warns "use of deprecated" for ".connect" in line 31.
Seems renamed to ".join".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.