Skip to content

Commit

Permalink
glib: Add GString::from_utf8_unchecked
Browse files Browse the repository at this point in the history
  • Loading branch information
jf2048 committed Mar 13, 2022
1 parent afc7b27 commit 294644d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions glib/src/gstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ unsafe impl Send for GString {}
unsafe impl Sync for GString {}

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

0 comments on commit 294644d

Please sign in to comment.