-
-
Notifications
You must be signed in to change notification settings - Fork 133
Open
Description
When using glib::Regex::match_() with an input string that does not match the pattern, the function panics in debug builds due to an incorrect assertion.
use glib::prelude::*;
use gtk::glib;
fn main() {
let rx = glib::Regex::new(
r"\d",
glib::RegexCompileFlags::DEFAULT,
glib::RegexMatchFlags::DEFAULT,
)
.unwrap()
.unwrap();
// This works (matches)
let input = glib::GString::from("8");
let _ = rx.match_(input.as_gstr(), glib::RegexMatchFlags::DEFAULT);
println!("Matched '8' - OK");
// This panics (no match)
let input = glib::GString::from("a");
let _ = rx.match_(input.as_gstr(), glib::RegexMatchFlags::DEFAULT);
println!("Matched 'a' - OK"); // Never reached
}Expected Behavior
match_() should return None when the input doesn't match the pattern.
Actual Behavior
Panic in debug builds:
panicked at /Users/me/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/glib-0.21.3/src/regex.rs:180:13:
assertion `left == right` failed
left: true
right: false
Environment
glib-rs version: 0.21.3
OS: macOS
Am I using match_() incorrectly? I expected it to return None when there's no match rather than panic. Any help would be appreciated!
Metadata
Metadata
Assignees
Labels
No labels