Skip to content

Commit e3253ff

Browse files
committed
glib: Add GString::from_utf8_unchecked
1 parent 319aba9 commit e3253ff

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

glib/src/gstring.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,12 @@ unsafe impl Send for GString {}
367367
unsafe impl Sync for GString {}
368368

369369
impl GString {
370+
// rustdoc-stripper-ignore-next
371+
/// Creates a GLib string by consuming a byte vector, without checking for UTF-8 or interior 0
372+
/// bytes. Trailing 0 byte will be appended by this function.
373+
pub unsafe fn from_utf8_unchecked(v: Vec<u8>) -> Self {
374+
GString(Inner::Native(Some(CString::from_vec_unchecked(v))))
375+
}
370376
// rustdoc-stripper-ignore-next
371377
/// Return the `GString` as string slice.
372378
pub fn as_str(&self) -> &str {

0 commit comments

Comments
 (0)