File tree Expand file tree Collapse file tree 2 files changed +32
-10
lines changed Expand file tree Collapse file tree 2 files changed +32
-10
lines changed Original file line number Diff line number Diff line change @@ -1605,16 +1605,11 @@ macro_rules! tuple_impls {
1605
1605
$( $name: StaticVariantType , ) +
1606
1606
{
1607
1607
fn static_variant_type( ) -> Cow <' static , VariantTy > {
1608
- let mut builder = crate :: GStringBuilder :: new( "(" ) ;
1609
-
1610
- $(
1611
- let t = $name:: static_variant_type( ) ;
1612
- builder. append( t. as_str( ) ) ;
1613
- ) +
1614
-
1615
- builder. append_c( ')' ) ;
1616
-
1617
- Cow :: Owned ( VariantType :: from_string( builder. into_string( ) ) . unwrap( ) )
1608
+ Cow :: Owned ( VariantType :: new_tuple( & [
1609
+ $(
1610
+ $name:: static_variant_type( ) ,
1611
+ ) +
1612
+ ] ) )
1618
1613
}
1619
1614
}
1620
1615
Original file line number Diff line number Diff line change @@ -64,6 +64,21 @@ impl VariantType {
64
64
unsafe { from_glib_full ( ffi:: g_variant_type_new_maybe ( child_type. to_glib_none ( ) . 0 ) ) }
65
65
}
66
66
67
+ // rustdoc-stripper-ignore-next
68
+ /// Creates a `VariantType` from a maybe element type.
69
+ #[ doc( alias = "g_variant_type_new_tuple" ) ]
70
+ pub fn new_tuple < T : AsRef < VariantTy > , I : IntoIterator < Item = T > > ( items : I ) -> VariantType {
71
+ let mut builder = crate :: GStringBuilder :: new ( "(" ) ;
72
+
73
+ for ty in items {
74
+ builder. append ( ty. as_ref ( ) . as_str ( ) ) ;
75
+ }
76
+
77
+ builder. append_c ( ')' ) ;
78
+
79
+ VariantType :: from_string ( builder. into_string ( ) ) . unwrap ( )
80
+ }
81
+
67
82
// rustdoc-stripper-ignore-next
68
83
/// Tries to create a `VariantType` from an owned string.
69
84
///
@@ -91,6 +106,12 @@ impl Drop for VariantType {
91
106
}
92
107
}
93
108
109
+ impl AsRef < VariantTy > for VariantType {
110
+ fn as_ref ( & self ) -> & VariantTy {
111
+ self
112
+ }
113
+ }
114
+
94
115
impl Borrow < VariantTy > for VariantType {
95
116
fn borrow ( & self ) -> & VariantTy {
96
117
self
@@ -631,6 +652,12 @@ impl<'a> From<&'a VariantTy> for Cow<'a, VariantTy> {
631
652
}
632
653
}
633
654
655
+ impl AsRef < VariantTy > for VariantTy {
656
+ fn as_ref ( & self ) -> & Self {
657
+ self
658
+ }
659
+ }
660
+
634
661
impl ToOwned for VariantTy {
635
662
type Owned = VariantType ;
636
663
You can’t perform that action at this time.
0 commit comments