Skip to content

example code fails to build with Mitosis trait bound not implemented #156

@ai-mannamalai

Description

@ai-mannamalai

Using the published Crate:

genetic-rs = { version = "1.4.1", features = ["rayon"] }

e.g.

   |
22 | pub trait Mitosis: Clone {
   | ^^^^^^^^^^^^^^^^^^^^^^^^
   = note: the full name for the type has been written to '/Users/muthu/devel/rust_to_cpp/target/debug/deps/rust_to_cpp-6b2d4692d9a2d3fc.long-type-9223394032506677038.txt'
   = note: consider using `--verbose` to print the full type name to the console

error[E0277]: the trait bound `MyGenome: genetic_rs::prelude::Mitosis` is not satisfied
  --> src/main.rs:54:39
   |
54 |         MitosisRepopulator::new(0.25, ()), // 25% mutation rate, empty context
   |                                       ^^ unsatisfied trait bound
   |
help: the trait `genetic_rs::prelude::Mitosis` is not implemented for `MyGenome`
  --> src/main.rs:20:1
   |

Add a code for implementation of trait like following is what lets me go through the compiler; I'm using rustc version 1.91.1

// use auto derives for the builtin nextgen functions to work with your genome.
impl Mitosis for MyGenome {
    type Context = ();

    fn divide(&self, _: &(), rate: f32, rng: &mut impl Rng) -> Self {
        let mut child = self.clone();
        child.mutate(&(), rate, rng);
        child
    }
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentation

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions