From b198984fc54ade649ea009b53f45f67a0de08662 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 16 Nov 2018 14:06:04 -0800 Subject: [PATCH] implement From for Expression-types --- schala-lang/language/src/ast.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/schala-lang/language/src/ast.rs b/schala-lang/language/src/ast.rs index 973389d..19e28d2 100644 --- a/schala-lang/language/src/ast.rs +++ b/schala-lang/language/src/ast.rs @@ -1,4 +1,7 @@ use std::rc::Rc; +use std::convert::From; + +use source_map::{SourceMap}; use builtin::{BinOp, PrefixOp}; @@ -63,6 +66,12 @@ pub enum Variant { #[derive(Debug, PartialEq, Clone)] pub struct Expression(pub ExpressionType, pub Option); +impl From for SourceMap { + fn from(node: Expression) -> Self { + SourceMap { node, data: None } + } +} + #[derive(Debug, PartialEq, Clone)] pub enum TypeIdentifier { Tuple(Vec), @@ -116,6 +125,13 @@ pub enum ExpressionType { }, ListLiteral(Vec), } + +impl From for SourceMap { + fn from(node: ExpressionType) -> Self { + SourceMap { node, data: None } + } +} + #[derive(Debug, PartialEq, Clone)] pub enum Discriminator { Simple(Expression),