Skip to content

Genetic-rs 1.3.0

Choose a tag to compare

@HyperCodec HyperCodec released this 02 Mar 19:12
· 59 commits to main since this release
2efb831

A small QoL/bugfix update. Here's a list of changes:

  • New FitnessObserver layering API. Allows you to chain FitnessObservers via foo.layer(bar).layer(...)
  • Many of the GeneticSim-owned traits of the crate, including FitnessObserver, Eliminator, and Repopulator, now take &mut self instead of &self. This should make it more convenient to deal with internal state.
  • doc-related fix that should make feature doc badges generate automatically.

Migration Guide

In any FitnessObserver, Eliminator, or Repopulator, you must now replace any &self with &mut self:

impl FitnessObserver<MyGenome> for Foo {
-   fn observe(&self, genomes: &[(MyGenome, f32)])
+   fn observe(&mut self, genomes: &[(MyGenome, f32)])
    {
         // ...
    }
}

impl<G> Eliminator<G> for Bar {
-   fn eliminate(&self, genomes: Vec<G>) -> Vec<G>
+   fn eliminate(&mut self, genomes: Vec<G>) -> Vec<G>
    {
        // ...
    }
}

impl<G> Repopulate<G> for Buzz {
-   fn repopulate(&self, genomes: &mut Vec<G>, target_size: usize)
+   fn repopulate(&mut self, genomes: &mut Vec<G>, target_size: usize)
    {
        // ...
    }
}

What's Changed

  • Add observer layering API via LayeredObserver and FitnessObserver::layer by @Copilot in #135
  • Fix feature docs not showing up on docs.rs by @Copilot in #136
  • Allow FitnessObserver::observe and Repopulator::repopulate to take &mut self by @Copilot in #139
  • Update 1.3.0 by @HyperCodec in #137

Full Changelog: 1.2.2...1.3.0