How to make this function work?
fn BoxIt(s: &str) -> Box<Iterator<Item = char>> {
return Box::new(s.chars());
}
I guess I should associate the lifetime of the String and the Chars object, do I?
And more how to complete this function ?
fn BoxIt2<T: Iterator<Item = char>>(s: T) -> Box<Iterator<Item = char>> {
return Box::new(s);
}
Actually,I ask above questions,because I want to make a struct:
struct CharStream {
stream: Box<Iterator<Item = char>>,
current: Option<char>,
}
Is it correct to use Box here?