Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "qsolve"
version = "1.0.1"
authors = ["Dan Schafer <dan.schafer@gmail.com>"]
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"
Expand Down
2 changes: 1 addition & 1 deletion src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub fn analyze_grid_image(img: &RgbImage) -> Result<QueensFile> {

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()
)
})?;
Expand Down
10 changes: 9 additions & 1 deletion src/solvestate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl SquareVal {
' ' => Ok(None),
'.' => Ok(None),
'_' => Ok(None),
_ => bail!("Blank"),
_ => bail!("Invalid square value character: {c:?}"),
}
}
}
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions src/squarecolor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ 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<char>` 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<SquareColor>` for [AnsiColors] allows for conversion from a [SquareColor] to an [AnsiColors] for printing squares to the terminal.
/// * [SquareColor::to_unicode_block] returns the unicode block character for the color. This is useful for generating the share text for a solution.
///
/// 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'.
Expand All @@ -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,
Expand All @@ -45,15 +45,15 @@ 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,
/// The Bright White ANSI color, represented by [char] 'W'.
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,
Expand Down
Loading