How can I save a string and the CharIndices returned by calling the char_indices() method on this string in the same struct? I other words how do I make the following work?
use std::str::CharIndices;
struct MyStruct<'a> {
input: String,
chars: CharIndices<'a>,
}
impl<'a> MyStruct<'a> {
fn new(inp: String) -> MyStruct<'a> {
MyStruct{ input: inp, chars: inp.char_indices() }
}
}
fn main() {
let s = MyStruct::new("test".into());
}