pub trait MapState: Clone + Debug {
// Required methods
fn is_expandable(&self) -> bool;
fn is_closed(&self) -> bool;
fn closed() -> Self;
}Expand description
Map が状態型 S に要求する制約
Map は状態の「意味」を知らない。Map が興味を持つのは2点のみ:
- Expandable: 子ノード追加可能(フロンティアとして管理)
- Closed: 終了(フロンティアから除外)
具体的な状態の詳細(Unexplored/Exploring/Explored/DeadEnd/Completed/Processing 等)は
この trait を実装する型で自由に定義できる。Map はそれらを
is_expandable() / is_closed() で抽象化して扱う。
§例: カスタム状態型
ⓘ
#[derive(Clone, Debug)]
enum MyState {
Pending, // → Expandable
Processing, // → neither (Map は関与しない)
Completed, // → Closed
Failed, // → Closed
}
impl MapState for MyState {
fn is_expandable(&self) -> bool {
matches!(self, Self::Pending)
}
fn is_closed(&self) -> bool {
matches!(self, Self::Completed | Self::Failed)
}
fn closed() -> Self {
Self::Completed
}
}Required Methods§
Sourcefn is_expandable(&self) -> bool
fn is_expandable(&self) -> bool
フロンティアとして展開可能か
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.