Skip to content

Commit

Permalink
glib: Add bindings for g_value_set_static_string() and `g_value_set…
Browse files Browse the repository at this point in the history
…_interned_string()`
  • Loading branch information
sdroege committed May 23, 2024
1 parent 470a75d commit 9786d23
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions glib/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use crate::{
prelude::*,
translate::*,
types::{Pointee, Pointer, Type},
GStr,
};

// rustdoc-stripper-ignore-next
Expand Down Expand Up @@ -537,6 +538,33 @@ impl Value {
unsafe { Value::from_type_unchecked(T::Type::static_type()) }
}

// rustdoc-stripper-ignore-next
/// Creates a new `String`-typed `Value` from a `'static` string.
#[inline]
#[doc(alias = "g_value_set_static_string")]
pub fn from_static_str(s: &'static GStr) -> Self {
unsafe {
let mut v = Self::from_type_unchecked(Type::STRING);
gobject_ffi::g_value_set_static_string(v.to_glib_none_mut().0, s.as_ptr());
v
}
}

#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
// rustdoc-stripper-ignore-next
/// Creates a new `String`-typed `Value` from a `'static` string that is also assumed to be
/// interned.
#[inline]
#[doc(alias = "g_value_set_interned_string")]
pub fn from_interned_str(s: &'static GStr) -> Self {
unsafe {
let mut v = Self::from_type_unchecked(Type::STRING);
gobject_ffi::g_value_set_interned_string(v.to_glib_none_mut().0, s.as_ptr());
v
}
}

// rustdoc-stripper-ignore-next
/// Tries to get a value of type `T`.
///
Expand Down

0 comments on commit 9786d23

Please sign in to comment.