@@ -856,14 +856,27 @@ impl StrV {
856
856
/// Joins the strings into a longer string, with an optional separator
857
857
#[ inline]
858
858
#[ doc( alias = "g_strjoinv" ) ]
859
- pub fn join ( self , separator : Option < impl IntoGStr > ) -> GString {
859
+ pub fn join ( & self , separator : Option < impl IntoGStr > ) -> GString {
860
860
separator. run_with_gstr ( |separator| unsafe {
861
861
from_glib_full ( ffi:: g_strjoinv (
862
862
separator. to_glib_none ( ) . 0 ,
863
863
self . ptr . as_ptr ( ) ,
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,30 @@ mod test {
1474
1487
assert_eq ! ( s, items) ;
1475
1488
} ) ;
1476
1489
}
1490
+
1491
+ #[ test]
1492
+ fn test_join ( ) {
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_eq ! ( strv. join( None :: <& str >) , "str1str2str3" ) ;
1501
+ assert_eq ! ( strv. join( Some ( "," ) ) , "str1,str2,str3" ) ;
1502
+ }
1503
+
1504
+ #[ test]
1505
+ fn test_contains ( ) {
1506
+ let items = [
1507
+ crate :: gstr!( "str1" ) ,
1508
+ crate :: gstr!( "str2" ) ,
1509
+ crate :: gstr!( "str3" ) ,
1510
+ ] ;
1511
+
1512
+ let strv = StrV :: from ( & items[ ..] ) ;
1513
+ assert ! ( strv. contains( "str2" ) ) ;
1514
+ assert ! ( !strv. contains( "str4" ) ) ;
1515
+ }
1477
1516
}
0 commit comments