Debian Codegraph @

debian/missing-sources/glib/tests/regex_compiletest/01-not-dangling.rs

raw
1 fn main() {
2 let r = glib::Regex::new(
3 "hello",
4 glib::RegexCompileFlags::DEFAULT,
5 glib::RegexMatchFlags::DEFAULT,
6 )
7 .unwrap()
8 .unwrap();
9 // implicit drop
10 {
11 let s = glib::GString::from("hello");
12 let match_info = r
13 .match_(s.as_gstr(), glib::RegexMatchFlags::DEFAULT)
14 .expect("should match");
15 assert_eq!(match_info.fetch_all(), vec!["hello"]);
16 // match_info is dropped
17 // s is dropped
18 }
19 // explicit drop
20 {
21 let s = glib::GString::from("hello");
22 let match_info = r
23 .match_(s.as_gstr(), glib::RegexMatchFlags::DEFAULT)
24 .expect("should match");
25 assert_eq!(match_info.fetch_all(), vec!["hello"]);
26 drop(match_info);
27 drop(s);
28 }
29 }