File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -864,6 +864,19 @@ impl StrV {
864
864
) )
865
865
} )
866
866
}
867
+
868
+ // rustdoc-stripper-ignore-next
869
+ /// Checks whether the `StrV` contains the specified string
870
+ #[ inline]
871
+ #[ doc( alias = "g_strv_contains" ) ]
872
+ pub fn contains ( & self , s : impl IntoGStr ) -> bool {
873
+ s. run_with_gstr ( |s| unsafe {
874
+ from_glib ( ffi:: g_strv_contains (
875
+ self . ptr . as_ptr ( ) as * const _ ,
876
+ s. to_glib_none ( ) . 0 ,
877
+ ) )
878
+ } )
879
+ }
867
880
}
868
881
869
882
impl FromGlibContainer < * mut c_char , * mut * mut c_char > for StrV {
@@ -1474,4 +1487,17 @@ mod test {
1474
1487
assert_eq ! ( s, items) ;
1475
1488
} ) ;
1476
1489
}
1490
+
1491
+ #[ test]
1492
+ fn test_contains ( ) {
1493
+ let items = [
1494
+ crate :: gstr!( "str1" ) ,
1495
+ crate :: gstr!( "str2" ) ,
1496
+ crate :: gstr!( "str3" ) ,
1497
+ ] ;
1498
+
1499
+ let strv = StrV :: from ( & items[ ..] ) ;
1500
+ assert ! ( strv. contains( "str2" ) ) ;
1501
+ assert ! ( !strv. contains( "str4" ) ) ;
1502
+ }
1477
1503
}
You can’t perform that action at this time.
0 commit comments