pub struct RegisteredObjective<T: Send + Sync> {
pub name: String,
pub description: Option<String>,
/* private fields */
}Expand description
A type-erased objective wrapper.
Fields§
§name: String§description: Option<String>Implementations§
Source§impl<T: Send + Sync> RegisteredObjective<T>
impl<T: Send + Sync> RegisteredObjective<T>
Sourcepub fn new(name: impl Into<String>, objective: Box<dyn Objective<T>>) -> Self
pub fn new(name: impl Into<String>, objective: Box<dyn Objective<T>>) -> Self
Create a new registered objective with the given name and no description.
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Attach a human-readable description to this registered objective.
Sourcepub fn score(&self, candidate: &T, context: &ObjectiveContext) -> f64
pub fn score(&self, candidate: &T, context: &ObjectiveContext) -> f64
Raw score (no precision weighting). Use select() for ranked selection with salience boost.
Sourcepub fn select<'a>(
&self,
candidates: &'a [T],
context: &ObjectiveContext,
) -> ObjectiveResult<Selection<&'a T>>
pub fn select<'a>( &self, candidates: &'a [T], context: &ObjectiveContext, ) -> ObjectiveResult<Selection<&'a T>>
Select the best candidate according to this objective’s ranking.
Returns ObjectiveError::NoMatch when the candidate slice is empty.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for RegisteredObjective<T>
impl<T> !UnwindSafe for RegisteredObjective<T>
impl<T> Freeze for RegisteredObjective<T>
impl<T> Send for RegisteredObjective<T>
impl<T> Sync for RegisteredObjective<T>
impl<T> Unpin for RegisteredObjective<T>
impl<T> UnsafeUnpin for RegisteredObjective<T>
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