Implement NonIntegerConstant::into_typed_value. r=jsantell

This commit is contained in:
Richard Newman 2017-02-09 16:59:35 -08:00
parent 1aa33423dc
commit fc73bfce75
2 changed files with 16 additions and 0 deletions

View file

@ -6,3 +6,6 @@ version = "0.0.1"
[dependencies.edn]
path = "../edn"
[dependencies.mentat_core]
path = "../core"

View file

@ -31,9 +31,11 @@
///! a tradeoff against well-typed function signatures and other such boundaries.
extern crate edn;
extern crate mentat_core;
use edn::{BigInt, OrderedFloat};
pub use edn::{NamespacedKeyword, PlainSymbol};
use mentat_core::TypedValue;
pub type SrcVarName = String; // Do not include the required syntactic '$'.
@ -101,6 +103,17 @@ pub enum NonIntegerConstant {
Text(String),
}
impl NonIntegerConstant {
pub fn into_typed_value(self) -> TypedValue {
match self {
NonIntegerConstant::BigInteger(_) => unimplemented!(), // TODO: #280.
NonIntegerConstant::Boolean(v) => TypedValue::Boolean(v),
NonIntegerConstant::Float(v) => TypedValue::Double(v),
NonIntegerConstant::Text(v) => TypedValue::String(v),
}
}
}
pub enum FnArg {
Variable(Variable),
SrcVar(SrcVar),