use nodify::prelude::*;
use std::iter::once;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct FiboNode {
pub previous: u64,
pub current: u64,
}
impl FiboNode {
pub fn first() -> Self {
Self {
previous: 0,
current: 1,
}
}
}
impl Node for FiboNode {
fn outgoing(self) -> impl Iterator<Item = Self> {
let next = Self {
previous: self.current,
current: self.previous + self.current,
};
once(next)
}
}
fn main() {
let first = FiboNode::first();
let result = first
.process::<DFS<_>>()
.contains_any(|FiboNode { current, .. }| current == 610);
println!("{first:?} => {result}");
}