File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -1239,10 +1239,7 @@ impl ToVariant for std::ffi::OsStr {
1239
1239
1240
1240
impl < T : StaticVariantType > StaticVariantType for Option < T > {
1241
1241
fn static_variant_type ( ) -> Cow < ' static , VariantTy > {
1242
- unsafe {
1243
- let ptr = ffi:: g_variant_type_new_maybe ( T :: static_variant_type ( ) . to_glib_none ( ) . 0 ) ;
1244
- Cow :: Owned ( from_glib_full ( ptr) )
1245
- }
1242
+ Cow :: Owned ( VariantType :: new_maybe ( & T :: static_variant_type ( ) ) )
1246
1243
}
1247
1244
}
1248
1245
Original file line number Diff line number Diff line change @@ -57,6 +57,13 @@ impl VariantType {
57
57
unsafe { from_glib_full ( ffi:: g_variant_type_new_array ( elem_type. to_glib_none ( ) . 0 ) ) }
58
58
}
59
59
60
+ // rustdoc-stripper-ignore-next
61
+ /// Creates a `VariantType` from a maybe element type.
62
+ #[ doc( alias = "g_variant_type_new_maybe" ) ]
63
+ pub fn new_maybe ( child_type : & VariantTy ) -> VariantType {
64
+ unsafe { from_glib_full ( ffi:: g_variant_type_new_maybe ( child_type. to_glib_none ( ) . 0 ) ) }
65
+ }
66
+
60
67
// rustdoc-stripper-ignore-next
61
68
/// Tries to create a `VariantType` from an owned string.
62
69
///
You can’t perform that action at this time.
0 commit comments