pub trait MoveCursor<S: PlanningSolution, M: Move<S>> {
// Required methods
fn next_candidate(&mut self) -> Option<CandidateId>;
fn candidate(&self, id: CandidateId) -> Option<MoveCandidateRef<'_, S, M>>;
fn take_candidate(&mut self, id: CandidateId) -> M;
// Provided methods
fn next_candidate_with_control<ShouldStop>(
&mut self,
should_stop: &mut ShouldStop,
) -> Option<CandidateId>
where ShouldStop: FnMut() -> bool { ... }
fn next_owned_candidate(&mut self) -> Option<M> { ... }
fn next_owned_candidate_matching(
&mut self,
predicate: for<'a> fn(MoveCandidateRef<'a, S, M>) -> bool,
) -> Option<M> { ... }
fn next_owned_candidate_inspected<T, F>(
&mut self,
inspect: F,
) -> Option<(M, T)>
where F: for<'a> FnMut(MoveCandidateRef<'a, S, M>) -> Option<T> { ... }
fn apply_owned_candidate<D: Director<S>>(
&mut self,
id: CandidateId,
score_director: &mut D,
) { ... }
fn release_candidate(&mut self, id: CandidateId) -> bool { ... }
fn selector_index(&self, _id: CandidateId) -> Option<usize> { ... }
}Expand description
Incremental, cursor-owned candidate storage for a single neighborhood.
next_candidate() constructs or discovers at most the next candidate and
returns a stable ID. A consumer may stop at any time: dropping the cursor
must release all retained candidates and any unconsumed source state without
requiring the remaining neighborhood to be enumerated. Implementations must
not rely on full exhaustion for correctness, callback delivery, or cleanup.
Candidates remain borrowable until they are released or transferred. The
selected candidate is consumed exactly once through take_candidate() or
apply_owned_candidate(); unselected live candidates remain cursor-owned.
Required Methods§
fn next_candidate(&mut self) -> Option<CandidateId>
fn candidate(&self, id: CandidateId) -> Option<MoveCandidateRef<'_, S, M>>
fn take_candidate(&mut self, id: CandidateId) -> M
Provided Methods§
Sourcefn next_candidate_with_control<ShouldStop>(
&mut self,
should_stop: &mut ShouldStop,
) -> Option<CandidateId>
fn next_candidate_with_control<ShouldStop>( &mut self, should_stop: &mut ShouldStop, ) -> Option<CandidateId>
Pulls the next candidate while allowing expensive cursor implementations
to observe solve control between units of generation work. A None
result may mean either exhaustion or requested interruption, so callers
must recheck the same control signal before resolving an exhausted scan.
fn next_owned_candidate(&mut self) -> Option<M>
fn next_owned_candidate_matching( &mut self, predicate: for<'a> fn(MoveCandidateRef<'a, S, M>) -> bool, ) -> Option<M>
fn next_owned_candidate_inspected<T, F>(&mut self, inspect: F) -> Option<(M, T)>
fn apply_owned_candidate<D: Director<S>>( &mut self, id: CandidateId, score_director: &mut D, )
fn release_candidate(&mut self, id: CandidateId) -> bool
fn selector_index(&self, _id: CandidateId) -> Option<usize>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".