pub trait ToVariantEq: Eq { }
Expand description

Trait for types whose ToVariant implementations preserve equivalence.

This means that for all values a and b, a == b is equivalent to a.to_variant() == b.to_variant(). Most of the time, this means that to_variant must return a “value” type, such as a primitive i32, a GodotString, or a PoolArray.

This is mostly useful as a bound for Dictionary keys, where the difference between Rust’s structural equality and Godot’s referential equality semantics can lead to surprising behaviors.

This property cannot be checked by the compiler, so ToVariantEq has no extra methods.

Implementing ToVariantEq

The ToVariantEq trait is not derivable, because most derived implementations of ToVariant don’t satisfy the requirements. If you are sure that your type satisfies the trait, specify that your type implements it with an empty impl:

#[derive(Eq, PartialEq, ToVariant)]
struct MyTypedInt(i32);

impl ToVariantEq for MyTypedInt {}

Implementations on Foreign Types

Implementors