astrai 2.2.0

A pretty bad neural network library
Documentation
use super::*;


#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Connection {
    pub in_neuron_id: NeuronID,
    pub out_neuron_id: NeuronID,
    pub weight: f64,
    pub enabled: bool,
}

impl PartialEq for Connection {
    fn eq(&self, other: &Self) -> bool {
        self.in_neuron_id == other.in_neuron_id
            && self.out_neuron_id == other.out_neuron_id
            && self.weight == other.weight
            && self.enabled == other.enabled
    }
}

impl Eq for Connection {}

impl std::hash::Hash for Connection {
    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
        self.in_neuron_id.hash(state);
        self.out_neuron_id.hash(state);
        self.weight.to_bits().hash(state);
        self.enabled.hash(state);
    }
}