Skip to content

Commit

Permalink
Merge pull request #989 from pbor/strvjoin
Browse files Browse the repository at this point in the history
strv: add join() method
  • Loading branch information
sdroege authored Feb 16, 2023
2 parents a635857 + 0ce2cbd commit 1fddbfd
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion glib/src/collections/strv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

use crate::{translate::*, GStr, GString, GStringPtr};
use crate::{translate::*, GStr, GString, GStringPtr, IntoGStr, IntoOptionalGStr};

// rustdoc-stripper-ignore-next
/// Minimum size of the `StrV` allocation.
Expand Down Expand Up @@ -851,6 +851,19 @@ impl StrV {
}
}
}

// rustdoc-stripper-ignore-next
/// Joins the strings into a longer string, with an optional separator
#[inline]
#[doc(alias = "g_strjoinv")]
pub fn join(self, separator: Option<impl IntoGStr>) -> GString {
separator.run_with_gstr(|separator| unsafe {
from_glib_full(ffi::g_strjoinv(
separator.to_glib_none().0,
self.ptr.as_ptr(),
))
})
}
}

impl FromGlibContainer<*mut c_char, *mut *mut c_char> for StrV {
Expand Down

0 comments on commit 1fddbfd

Please sign in to comment.