#[derive(Copy, Clone, Debug)]
pub struct Best<T: Copy + Default> {
pub best_fit: f64,
pub best_pos: T,
}
impl<T: Copy + Default> Best<T> {
#[must_use]
pub fn new() -> Self {
Self {
best_fit: f64::MIN,
best_pos: T::default(),
}
}
}
impl<T: Copy + Default> Default for Best<T> {
fn default() -> Self {
Self::new()
}
}
impl<'a, TSource, TTarget> From<&'a Best<TSource>> for Best<TTarget>
where
TSource: Copy + Default,
TTarget: From<TSource> + Copy + Default,
{
fn from(best: &'a Best<TSource>) -> Self {
Self {
best_fit: best.best_fit,
best_pos: best.best_pos.into(),
}
}
}