Pure Programmer
Blue Matrix


Cluster Map

Project: Palindrome Search

A [[palindrome]] is a word or phrase that is spelled the same when it is reversed. Write a program that searches a dictionary of English words to find ones that are palindromes and at least four characters in length. Pass the name of the dictionary file to search (one word per line) on the command line.

See Webster's Second International for a file that contains US English words (235k words from 1934 edition) or the open source file [[English Words]] on GitHub (466k words).

Output
$ rustc PalindromeSearch.rs error[E0432]: unresolved import `regex` --> PalindromeSearch.rs:8:5 | 8 | use regex::Regex; | ^^^^^ maybe a missing crate `regex`? | = help: consider adding `extern crate regex` to use the `regex` crate error[E0425]: cannot find value `ifh` in this scope --> PalindromeSearch.rs:32:11 | 32 | utf8mode(ifh); | ^^^ not found in this scope error[E0425]: cannot find value `ifh` in this scope --> PalindromeSearch.rs:34:21 | 34 | while getline(line,ifh) { | ^^^ not found in this scope error[E0425]: cannot find value `ifh` in this scope --> PalindromeSearch.rs:39:8 | 39 | close(ifh); | ^^^ not found in this scope error[E0425]: cannot find value `args` in this scope --> PalindromeSearch.rs:43:5 | 43 | if args.len() != 2 { | ^^^^ not found in this scope | help: consider importing this function | 8 + use std::env::args; | error[E0425]: cannot find function `exit` in this scope --> PalindromeSearch.rs:45:3 | 45 | exit(1); | ^^^^ not found in this scope | help: consider importing this function | 8 + use std::process::exit; | error[E0425]: cannot find value `args` in this scope --> PalindromeSearch.rs:47:28 | 47 | let mut filespec:String = args[1]; | ^^^^ not found in this scope | help: consider importing this function | 8 + use std::env::args; | error[E0425]: cannot find function `replaceAll` in this scope --> PalindromeSearch.rs:13:22 | 13 | let mut s0:String = replaceAll(s,Regex::new(r"\\W+").unwrap(),""); | ^^^^^^^^^^ not found in this scope error[E0425]: cannot find function `tolower` in this scope --> PalindromeSearch.rs:14:7 | 14 | s0 = tolower(s0); | ^^^^^^^ not found in this scope error[E0425]: cannot find function `strlen` in this scope --> PalindromeSearch.rs:15:19 | 15 | let sLen:isize = strlen(s0); | ^^^^^^ not found in this scope error[E0425]: cannot find function `utf8mode` in this scope --> PalindromeSearch.rs:32:2 | 32 | utf8mode(ifh); | ^^^^^^^^ not found in this scope error[E0425]: cannot find function `getline` in this scope --> PalindromeSearch.rs:34:8 | 34 | while getline(line,ifh) { | ^^^^^^^ not found in this scope error[E0425]: cannot find function `close` in this scope --> PalindromeSearch.rs:39:2 | 39 | close(ifh); | ^^^^^ not found in this scope error[E0308]: mismatched types --> PalindromeSearch.rs:31:37 | 31 | fn searchTextFile(filespec:&str) -> Result<(), Arc<dyn error::Error>> { | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<(), Arc<dyn Error>>`, found `()` | | | implicitly returns `()` as its body has no tail or `return` expression | = note: expected enum `Result<(), Arc<(dyn std::error::Error + 'static)>>` found unit type `()` error[E0433]: failed to resolve: use of undeclared crate or module `io` --> PalindromeSearch.rs:54:59 | 54 | if let Some(ex) = utils::isCustomErrorType(ex.clone(), io::Error("".to_string())){ | ^^ | | | use of undeclared crate or module `io` | help: a builtin type with a similar name exists: `i8` error: aborting due to 15 previous errors Some errors have detailed explanations: E0308, E0425, E0432, E0433. For more information about an error, try `rustc --explain E0308`.

Solution