Skip to content

Commit e85c03f

Browse files
committed
Migrate TechniqueFlags to flags.rs
1 parent 821c952 commit e85c03f

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use bitflags::bitflags;
2+
3+
bitflags! {
4+
/// Bitmask to control which human techniques are applied.
5+
#[repr(transparent)]
6+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7+
pub struct TechniqueFlags: u16 {
8+
/// Apply the naked singles technique.
9+
const NAKED_SINGLES = 1 << 0;
10+
/// Apply the hidden singles technique.
11+
const HIDDEN_SINGLES = 1 << 1;
12+
/// Apply the naked pairs technique.
13+
const NAKED_PAIRS = 1 << 2;
14+
/// Apply the hidden pairs technique.
15+
const HIDDEN_PAIRS = 1 << 3;
16+
/// Apply the locked candidates technique.
17+
const LOCKED_CANDIDATES = 1 << 4;
18+
/// Apply the X-Wing technique.
19+
const XWING = 1 << 5;
20+
21+
/// Apply easy techniques like naked singles and hidden singles.
22+
const EASY = Self::NAKED_SINGLES.bits() | Self::HIDDEN_SINGLES.bits();
23+
/// Apply medium techniques like naked pairs and hidden pairs.
24+
const MEDIUM = Self::NAKED_PAIRS.bits() | Self::HIDDEN_PAIRS.bits();
25+
/// Apply hard techniques like locked candidates and X-Wings.
26+
const HARD = Self::LOCKED_CANDIDATES.bits() | Self::XWING.bits();
27+
}
28+
}

rustoku-lib/src/core/techniques/mod.rs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,23 @@
11
use super::board::Board;
22
use super::candidates::Candidates;
33
use super::masks::Masks;
4-
use bitflags::bitflags;
54

5+
mod flags;
66
mod hidden_pairs;
77
mod hidden_singles;
88
mod locked_candidates;
99
mod naked_pairs;
1010
mod naked_singles;
1111
mod x_wing;
1212

13+
pub use flags::TechniqueFlags;
1314
use hidden_pairs::HiddenPairs;
1415
use hidden_singles::HiddenSingles;
1516
use locked_candidates::LockedCandidates;
1617
use naked_pairs::NakedPairs;
1718
use naked_singles::NakedSingles;
1819
use x_wing::XWing;
1920

20-
bitflags! {
21-
/// Bitmask to control which human techniques are applied.
22-
#[repr(transparent)]
23-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
24-
pub struct TechniqueFlags: u16 {
25-
/// Apply the naked singles technique.
26-
const NAKED_SINGLES = 1 << 0;
27-
/// Apply the hidden singles technique.
28-
const HIDDEN_SINGLES = 1 << 1;
29-
/// Apply the naked pairs technique.
30-
const NAKED_PAIRS = 1 << 2;
31-
/// Apply the hidden pairs technique.
32-
const HIDDEN_PAIRS = 1 << 3;
33-
/// Apply the locked candidates technique.
34-
const LOCKED_CANDIDATES = 1 << 4;
35-
/// Apply the X-Wing technique.
36-
const XWING = 1 << 5;
37-
38-
/// Apply easy techniques like naked singles and hidden singles.
39-
const EASY = Self::NAKED_SINGLES.bits() | Self::HIDDEN_SINGLES.bits();
40-
/// Apply medium techniques like naked pairs and hidden pairs.
41-
const MEDIUM = Self::NAKED_PAIRS.bits() | Self::HIDDEN_PAIRS.bits();
42-
/// Apply hard techniques like locked candidates and X-Wings.
43-
const HARD = Self::LOCKED_CANDIDATES.bits() | Self::XWING.bits();
44-
}
45-
}
46-
4721
// Now the actual implementation of the techniques, these would operate on
4822
// references to Board, Masks, and CandidatesCache.
4923
pub struct TechniquePropagator<'a> {

0 commit comments

Comments
 (0)