use std::fmt::Debug;
pub trait GenomeKind: Debug + Copy + Send + Sync + 'static {
const DIM: usize;
type Element: Copy + Debug + Send + Sync + 'static;
}
#[derive(Debug, Clone, Copy, Default)]
pub struct Real;
impl GenomeKind for Real {
const DIM: usize = 0;
type Element = f32;
}
#[derive(Debug, Clone, Copy, Default)]
pub struct Binary;
impl GenomeKind for Binary {
const DIM: usize = 0;
type Element = i32;
}
#[derive(Debug, Clone, Copy, Default)]
pub struct Integer;
#[derive(Debug, Clone, Copy, Default)]
pub struct Tree;
#[derive(Debug, Clone, Copy, Default)]
pub struct Permutation;
impl GenomeKind for Integer {
const DIM: usize = 0;
type Element = i32;
}
impl GenomeKind for Tree {
const DIM: usize = 0;
type Element = i32;
}
impl GenomeKind for Permutation {
const DIM: usize = 0;
type Element = i32;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn real_has_f32_element() {
let _: <Real as GenomeKind>::Element = 0.0_f32;
}
#[test]
fn binary_has_i32_element() {
let _: <Binary as GenomeKind>::Element = 1_i32;
}
#[test]
fn integer_has_i32_element() {
let _: <Integer as GenomeKind>::Element = 5_i32;
}
#[test]
fn permutation_has_i32_element() {
let _: <Permutation as GenomeKind>::Element = 7_i32;
}
#[test]
fn markers_are_debug() {
let _ = format!(
"{Real:?} {Binary:?} {Integer:?} {Tree:?} {Permutation:?}"
);
}
}