Skip to content

Commit

Permalink
Implement ToVariant and 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.

BREAKING CHANGE: This remove `impl<T: ToVariant> From<T> for Variant`,
which made it impossible to implement `ToVariant` since it conflicts
with the standard library `impl<T> From<T> for T`:
gtk-rs#678
  • Loading branch information
ids1024 committed Sep 4, 2020
1 parent a8b5db0 commit c9b6d40
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 c9b6d40

Please sign in to comment.