We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0d468c1 + 21d47a1 commit 36ef929Copy full SHA for 36ef929
glib/src/gstring.rs
@@ -1040,6 +1040,18 @@ impl std::hash::Hash for GStringPtr {
1040
}
1041
1042
1043
+impl<T: AsRef<str>> From<T> for GStringPtr {
1044
+ fn from(value: T) -> Self {
1045
+ unsafe {
1046
+ let value = value.as_ref();
1047
+ GStringPtr(ptr::NonNull::new_unchecked(ffi::g_strndup(
1048
+ value.as_ptr() as *const _,
1049
+ value.len(),
1050
+ )))
1051
+ }
1052
1053
+}
1054
+
1055
// size_of::<Inner>() minus two bytes for length and enum discriminant
1056
const INLINE_LEN: usize =
1057
mem::size_of::<Option<Box<str>>>() + mem::size_of::<usize>() - mem::size_of::<u8>() * 2;
0 commit comments