Skip to content

Commit

Permalink
glib: implement From<GStringPtr> for GString
Browse files Browse the repository at this point in the history
  • Loading branch information
jf2048 authored and sdroege committed Mar 11, 2023
1 parent 9903467 commit 94f97c2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions glib/src/gstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,15 @@ impl From<&String> for GString {
}
}

impl From<GStringPtr> for GString {
#[inline]
fn from(s: GStringPtr) -> Self {
let s = mem::ManuallyDrop::new(s);
let len = unsafe { GStr::from_ptr(s.0.as_ptr()).len() };
GString(Inner::Foreign { ptr: s.0, len })
}
}

impl TryFrom<CString> for GString {
type Error = GStringUtf8Error<CString>;
#[inline]
Expand Down

0 comments on commit 94f97c2

Please sign in to comment.