From ccba3c1dddd911ddc8f132c37da497d3aa9c010a Mon Sep 17 00:00:00 2001 From: Robert Wittams Date: Mon, 8 Feb 2021 14:22:43 +0000 Subject: [PATCH] Allow Key and KeyOrValue to be treated as Data --- druid/src/env.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/druid/src/env.rs b/druid/src/env.rs index b12ee1741d..910048b64a 100644 --- a/druid/src/env.rs +++ b/druid/src/env.rs @@ -87,7 +87,7 @@ struct EnvImpl { /// /// [`ValueType`]: trait.ValueType.html /// [`Env`]: struct.Env.html -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Data)] pub struct Key { key: &'static str, value_type: PhantomData, @@ -134,6 +134,16 @@ pub enum KeyOrValue { Key(Key), } +impl Data for KeyOrValue { + fn same(&self, other: &Self) -> bool { + match (self, other) { + (Self::Concrete(a), Self::Concrete(b)) => a.same(b), + (Self::Key(a), Self::Key(b)) => a.same(b), + _ => false, + } + } +} + /// A trait for anything that can resolve a value of some type from the [`Env`]. /// /// This is a generalization of the idea of [`KeyOrValue`], mostly motivated