pub fn check_word(word: &str, required: char, extra: &str) -> Option<Answer>
Expand description

Test if the given word is a valid answer to the spelling bee, and return scoring information if it is an answer. If the word is not an answer than None will be returned.

Notes

A word is considered an answer if it is at least four letters long, at least one character matches required, and the remaining letters match of the characters in extra or the required character. A pangram is when a word’s letters match both the required character, and every character listed in extra.

Scoring is determined with the following rules: 1. Words of length four are worth one point. 2. Words longer than four letters are worth their length in points. 3. A pangram word gets an additional seven points.

Examples

use spellingbee::check_word;
assert!(check_word("loon", 'o', "unrlap").is_some());
assert!(check_word("unpopular", 'o', "unrlap").unwrap().is_pangram);
assert_eq!(7, check_word("pronoun", 'o', "unrlap").unwrap().score);
assert!(check_word("foobar", 'o', "unrlap").is_none());