Skip to content

Commit

Permalink
Implement FromVariant for Variant
Browse files Browse the repository at this point in the history
This is useful when combined with the container variant functions and
trait implementations from gtk-rs#651.

Implementing `ToVariant` would be useful as well, but isn't currently
possible: gtk-rs#678
  • Loading branch information
ids1024 committed Sep 3, 2020
1 parent 4516a75 commit 9a11641
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,12 @@ where
}
}

impl FromVariant for Variant {
fn from_variant(variant: &Variant) -> Option<Self> {
Some(variant.clone())
}
}

impl<K: StaticVariantType, V: StaticVariantType> StaticVariantType for DictEntry<K, V> {
fn static_variant_type() -> Cow<'static, VariantTy> {
let key_type = K::static_variant_type();
Expand Down

0 comments on commit 9a11641

Please sign in to comment.