Skip to main content

BinaryGenome

Trait BinaryGenome 

Source
pub trait BinaryGenome: EvolutionaryGenome<Allele = bool> {
    // Required methods
    fn bits(&self) -> &[bool];
    fn bits_mut(&mut self) -> &mut [bool];
    fn from_bits(bits: Vec<bool>) -> Result<Self, GenomeError>;

    // Provided methods
    fn count_ones(&self) -> usize { ... }
    fn count_zeros(&self) -> usize { ... }
}
Expand description

Trait for genomes that can be represented as bit strings

Required Methods§

Source

fn bits(&self) -> &[bool]

Get the bits as a slice

Source

fn bits_mut(&mut self) -> &mut [bool]

Get the bits as a mutable slice

Source

fn from_bits(bits: Vec<bool>) -> Result<Self, GenomeError>

Create from a vector of bits

Provided Methods§

Source

fn count_ones(&self) -> usize

Count the number of true bits (ones)

Source

fn count_zeros(&self) -> usize

Count the number of false bits (zeros)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§