I'm trying to find all words that matching pattern of glib::Regex:
let re = Regex::new(®ex_key,
glib::RegexCompileFlags::MULTILINE, glib::RegexMatchFlags::DEFAULT)
.expect("Can't create Regex").expect("Can't create Regex");
let g_dict_body = glib::GString::from_string_unchecked(dict_body.into());
let words = re.match_(g_dict_body.as_gstr(),
glib::RegexMatchFlags::DEFAULT).expect("Can't get MatchInfo");
while words.matches(){
let word = words.fetch(0).expect("Can't get word");
let (word_start, word_end) =
words.fetch_pos(0).expect("Can't get word start and end.");
println!("word: {}, word start: {}, word end: {}",
word, word_start, word_end);
let _ = words.next();
}
But in the end of the loop it panics:
thread 'main' panicked at /.cargo/registry/src/index.crates.io-6f17d22bba15001f/glib-0.19.6/src/match_info.rs:335:13:
assertion left == right
failed
left: true
right: false
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace
How to fix that?