struct Fibonacci{
cur:u16,
next:u16
}
impl Fibonacci{
fn new()->Self{
Self{cur:0,next:1}
}
}
impl Iterator for Fibonacci{
type Item=u16;
fn next(&mut self)->Option<Self::Item>{
let new_next=self.cur+self.next;
self.cur=self.next;
self.next=new_next;
Some(self.cur)
}
}
fn main(){
let mut f1=Fibonacci::new();
for _ in 0..10{
print!("{:?}",f1.next().unwrap());
}
}