Skip to content

Commit 1fddbfd

Browse files
authored
Merge pull request #989 from pbor/strvjoin
strv: add join() method
2 parents a635857 + 0ce2cbd commit 1fddbfd

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

glib/src/collections/strv.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use std::{ffi::c_char, fmt, marker::PhantomData, mem, ptr};
44

5-
use crate::{translate::*, GStr, GString, GStringPtr};
5+
use crate::{translate::*, GStr, GString, GStringPtr, IntoGStr, IntoOptionalGStr};
66

77
// rustdoc-stripper-ignore-next
88
/// Minimum size of the `StrV` allocation.
@@ -851,6 +851,19 @@ impl StrV {
851851
}
852852
}
853853
}
854+
855+
// rustdoc-stripper-ignore-next
856+
/// Joins the strings into a longer string, with an optional separator
857+
#[inline]
858+
#[doc(alias = "g_strjoinv")]
859+
pub fn join(self, separator: Option<impl IntoGStr>) -> GString {
860+
separator.run_with_gstr(|separator| unsafe {
861+
from_glib_full(ffi::g_strjoinv(
862+
separator.to_glib_none().0,
863+
self.ptr.as_ptr(),
864+
))
865+
})
866+
}
854867
}
855868

856869
impl FromGlibContainer<*mut c_char, *mut *mut c_char> for StrV {

0 commit comments

Comments
 (0)