diff --git a/Cargo.toml b/Cargo.toml index 77c4305..df9ecb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "qsolve" version = "1.0.1" authors = ["Dan Schafer "] edition = "2024" -description = "A command-line tool for solving Queens puzzles" +description = "A library and command-line tool for solving Queens puzzles" documentation = "https://docs.rs/qsolve" readme = "README.md" repository = "https://github.com/dschafer/qsolve" diff --git a/src/image.rs b/src/image.rs index 3f13c8c..9bbf9d1 100644 --- a/src/image.rs +++ b/src/image.rs @@ -120,7 +120,7 @@ pub fn analyze_grid_image(img: &RgbImage) -> Result { let rgb_color = get_dominant_color(&view).with_context(|| { format!( - "Count not find dominant color in square at offset {:?}", + "Could not find dominant color in square at offset {:?}", view.offsets() ) })?; diff --git a/src/solvestate.rs b/src/solvestate.rs index 5b20e83..931b5b6 100644 --- a/src/solvestate.rs +++ b/src/solvestate.rs @@ -54,7 +54,7 @@ impl SquareVal { ' ' => Ok(None), '.' => Ok(None), '_' => Ok(None), - _ => bail!("Blank"), + _ => bail!("Invalid square value character: {c:?}"), } } } @@ -374,6 +374,14 @@ mod tests { } } + #[test] + fn squareval_reports_invalid_character() { + assert_eq!( + SquareVal::try_from('S').unwrap_err().to_string(), + "Invalid square value character: 'S'" + ); + } + #[test] fn solvestate_from_board() { let board = Board::from_str("wwww\nkkkk\nrrrr\nbbbb").unwrap(); diff --git a/src/squarecolor.rs b/src/squarecolor.rs index d5b256d..1b16784 100644 --- a/src/squarecolor.rs +++ b/src/squarecolor.rs @@ -7,8 +7,8 @@ use owo_colors::AnsiColors; /// Represents a color that can appear on the board. /// /// There are 16 possible colors, corresponding to the 16 ANSI colors -/// that most termianls support. The most critical traits and methods implemented on this -/// enum allow for easy converstion to and from different representations: +/// that most terminals support. The most critical traits and methods implemented on this +/// enum allow for easy conversion to and from different representations: /// /// * `TryFrom` for [SquareColor] allows for conversion from a [char] representation to a [SquareColor]. This is most notably used in parsing a [Board][crate::board::Board]. /// * `From` for [AnsiColors] allows for conversion from a [SquareColor] to an [AnsiColors] for printing squares to the terminal. @@ -16,7 +16,7 @@ use owo_colors::AnsiColors; /// /// Each color is represented by a [char]. The [char] is the first character of the color /// for all colors other than black; for black, we use 'k' (since 'b' is already used for blue, -/// and 'k' matches the CMYK tradition).Normal colors are lower-cased, and bright colors are +/// and 'k' matches the CMYK tradition). Normal colors are lower-cased, and bright colors are /// upper-cased (so "Bright Red" would be 'R'). pub enum SquareColor { /// The Black ANSI color, represented by [char] 'k'. @@ -29,7 +29,7 @@ pub enum SquareColor { Yellow, /// The Blue ANSI color, represented by [char] 'b'. Blue, - /// The Magenta ANSI color, represented by [char] 'k'. + /// The Magenta ANSI color, represented by [char] 'm'. Magenta, /// The Cyan ANSI color, represented by [char] 'c'. Cyan, @@ -45,7 +45,7 @@ pub enum SquareColor { BrightYellow, /// The Bright Blue ANSI color, represented by [char] 'B'. BrightBlue, - /// The Bright Magenta ANSI color, represented by [char] 'K'. + /// The Bright Magenta ANSI color, represented by [char] 'M'. BrightMagenta, /// The Bright Cyan ANSI color, represented by [char] 'C'. BrightCyan, @@ -53,7 +53,7 @@ pub enum SquareColor { BrightWhite, } -/// A convinience const that contains all square colors once. +/// A convenience constant that contains every square color once. pub const ALL_SQUARE_COLORS: [SquareColor; 16] = [ SquareColor::Black, SquareColor::Red,