use super::Block;
pub trait Node: Block {
type ConnectionInstructions: Clone + Default;
fn connect(
&mut self,
other: &mut Self,
instructions: &Self::ConnectionInstructions
);
}
#[cfg(test)] pub(crate) mod test {
use super::*;
use crate::block::test::TestBlock;
impl Node for TestBlock {
type ConnectionInstructions = u8;
fn connect(
&mut self,
other: &mut Self,
times: &Self::ConnectionInstructions
) {
for _ in 0..*times {
self.connections.push(other.id.clone())
}
}
}
#[test] fn node_connect_test() {
let mut a = TestBlock::create(&"a".to_string());
let mut b = TestBlock::create(&"b".to_string());
a.connect(&mut b, &1);
assert_eq!(a.connections[0], "b".to_string());
}
}