diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-08-21 16:38:51 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-08-21 17:30:21 +0200 |
| commit | 0dd4ae0a7ac0c247078df492469ff20b8a90c886 (patch) | |
| tree | 07a55343b9ccab3fe76b0f1b0de9d1be310d8b14 /src/eval/value.rs | |
| parent | f38eb10c2b54bd13ccef119454839f6a66448462 (diff) | |
Prune derives
Diffstat (limited to 'src/eval/value.rs')
| -rw-r--r-- | src/eval/value.rs | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/eval/value.rs b/src/eval/value.rs index 99efc2e5..5edf0362 100644 --- a/src/eval/value.rs +++ b/src/eval/value.rs @@ -144,6 +144,12 @@ impl From<usize> for Value { } } +impl From<RgbaColor> for Value { + fn from(v: RgbaColor) -> Self { + Self::Color(Color::Rgba(v)) + } +} + impl From<&str> for Value { fn from(v: &str) -> Self { Self::Str(v.into()) @@ -162,12 +168,6 @@ impl From<EcoString> for Value { } } -impl From<RgbaColor> for Value { - fn from(v: RgbaColor) -> Self { - Self::Color(Color::Rgba(v)) - } -} - impl From<Dynamic> for Value { fn from(v: Dynamic) -> Self { Self::Dyn(v) @@ -181,7 +181,7 @@ impl Dynamic { /// Create a new instance from any value that satisifies the required bounds. pub fn new<T>(any: T) -> Self where - T: Type + Debug + Display + Clone + PartialEq + 'static, + T: Type + Debug + Display + PartialEq + 'static, { Self(Rc::new(any)) } @@ -202,15 +202,15 @@ impl Dynamic { } } -impl Display for Dynamic { +impl Debug for Dynamic { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - Display::fmt(&self.0, f) + Debug::fmt(&self.0, f) } } -impl Debug for Dynamic { +impl Display for Dynamic { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - Debug::fmt(&self.0, f) + Display::fmt(&self.0, f) } } @@ -228,7 +228,7 @@ trait Bounds: Debug + Display + 'static { impl<T> Bounds for T where - T: Type + Debug + Display + Clone + PartialEq + 'static, + T: Type + Debug + Display + PartialEq + 'static, { fn as_any(&self) -> &dyn Any { self @@ -309,12 +309,6 @@ macro_rules! primitive { const TYPE_NAME: &'static str = $name; } - impl From<$type> for Value { - fn from(v: $type) -> Self { - Value::$variant(v) - } - } - impl Cast<Value> for $type { fn is(value: &Value) -> bool { matches!(value, Value::$variant(_) $(| Value::$other(_))*) @@ -332,6 +326,12 @@ macro_rules! primitive { } } } + + impl From<$type> for Value { + fn from(v: $type) -> Self { + Value::$variant(v) + } + } }; } @@ -342,17 +342,17 @@ macro_rules! dynamic { const TYPE_NAME: &'static str = $name; } - impl From<$type> for $crate::eval::Value { - fn from(v: $type) -> Self { - $crate::eval::Value::Dyn($crate::eval::Dynamic::new(v)) - } - } - castable! { $type: <Self as $crate::eval::Type>::TYPE_NAME, $($tts)* @this: Self => this.clone(), } + + impl From<$type> for $crate::eval::Value { + fn from(v: $type) -> Self { + $crate::eval::Value::Dyn($crate::eval::Dynamic::new(v)) + } + } }; } |
