diff --git a/glib/src/value.rs b/glib/src/value.rs index a462b84a735c..cbe2e40e40e5 100644 --- a/glib/src/value.rs +++ b/glib/src/value.rs @@ -565,6 +565,22 @@ impl Value { } } + // rustdoc-stripper-ignore-next + /// Tries to transform the value into the target type + #[doc(alias = "g_value_transform")] + pub fn get_transformed(&self) -> Result { + self.transform::().and_then(|v| { + v.get().map_err(|e| { + crate::bool_error!( + "Can't transform value of type '{}' into '{}': {}", + self.type_(), + T::Type::static_type(), + e + ) + }) + }) + } + // rustdoc-stripper-ignore-next /// Returns `true` if the type of the value corresponds to `T` /// or is a sub-type of `T`.