Skip to content

Commit 4f30a03

Browse files
authored
Merge pull request #1413 from sdroege/send-value-from-value-unsafe
glib: Add unsafe `Value::into_send_value()`
2 parents d22c24f + 818cd14 commit 4f30a03

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

glib/src/value.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,9 @@ impl Value {
666666
}
667667
}
668668

669+
// rustdoc-stripper-ignore-next
670+
/// Converts a `Value` into a `SendValue`. This fails if `self` does not store a value of type
671+
/// `T`. It is required for `T` to be `Send` to call this function.
669672
#[inline]
670673
pub fn try_into_send_value<T: Send + StaticType>(self) -> Result<SendValue, Self> {
671674
if self.type_().is_a(T::static_type()) {
@@ -675,6 +678,17 @@ impl Value {
675678
}
676679
}
677680

681+
// rustdoc-stripper-ignore-next
682+
/// Converts a `Value` into a `SendValue`.
683+
///
684+
/// # Safety
685+
///
686+
/// The type of the value contained in `self` must be `Send`.
687+
#[inline]
688+
pub unsafe fn into_send_value(self) -> SendValue {
689+
SendValue::unsafe_from(self.into_raw())
690+
}
691+
678692
fn content_debug_string(&self) -> GString {
679693
unsafe { from_glib_full(gobject_ffi::g_strdup_value_contents(self.to_glib_none().0)) }
680694
}

0 commit comments

Comments
 (0)