pub struct ScoreWeightedSelector;Expand description
Stateless selector that picks the highest-scoring ScoredCandidate.
Ties are broken by registration order (the first candidate in the input
vector wins). An empty input returns None.
§Example
use stygian_plugin::reliability::{ReliabilityScore, ScoreWeightedSelector, ScoredCandidate};
let candidates = vec![
ScoredCandidate::new("primary", ReliabilityScore::from_overall(0.6)),
ScoredCandidate::new("plugin", ReliabilityScore::from_overall(0.9)),
];
let winner = ScoreWeightedSelector::pick_best(candidates).unwrap();
assert_eq!(winner.name, "plugin");Implementations§
Source§impl ScoreWeightedSelector
impl ScoreWeightedSelector
Sourcepub fn pick_best(candidates: Vec<ScoredCandidate>) -> Option<ScoredCandidate>
pub fn pick_best(candidates: Vec<ScoredCandidate>) -> Option<ScoredCandidate>
Pick the highest-scoring candidate. Returns None for an empty input.
The first candidate with the maximum score wins on ties — this preserves the registration order so callers retain deterministic control over tie-breaking.
Sourcepub fn pick_best_ref(candidates: &[ScoredCandidate]) -> Option<&ScoredCandidate>
pub fn pick_best_ref(candidates: &[ScoredCandidate]) -> Option<&ScoredCandidate>
Pick the highest-scoring candidate by reference. Useful when the caller already owns the candidates and does not want to move them.
Trait Implementations§
Source§impl Clone for ScoreWeightedSelector
impl Clone for ScoreWeightedSelector
Source§fn clone(&self) -> ScoreWeightedSelector
fn clone(&self) -> ScoreWeightedSelector
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ScoreWeightedSelector
Source§impl Debug for ScoreWeightedSelector
impl Debug for ScoreWeightedSelector
Source§impl Default for ScoreWeightedSelector
impl Default for ScoreWeightedSelector
Source§fn default() -> ScoreWeightedSelector
fn default() -> ScoreWeightedSelector
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ScoreWeightedSelector
impl RefUnwindSafe for ScoreWeightedSelector
impl Send for ScoreWeightedSelector
impl Sync for ScoreWeightedSelector
impl Unpin for ScoreWeightedSelector
impl UnsafeUnpin for ScoreWeightedSelector
impl UnwindSafe for ScoreWeightedSelector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more