From 1ddfbef09140759f1feb2515879c85790076a91d Mon Sep 17 00:00:00 2001 From: Ziyang Hu Date: Fri, 29 Apr 2022 22:11:31 +0800 Subject: [PATCH] coercion the easy cases --- src/relation/typing.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/relation/typing.rs b/src/relation/typing.rs index 7f7cad60..7bc72305 100644 --- a/src/relation/typing.rs +++ b/src/relation/typing.rs @@ -107,9 +107,7 @@ impl Typing { _ => unreachable!() }) } - pub fn is_nullable(&self) -> bool { - matches!(self, Typing::Any | Typing::Nullable(_)) - } + pub fn coerce<'a>(&self, v: Value<'a>) -> Result> { if *self == Typing::Any { return Ok(v); @@ -127,8 +125,6 @@ impl Typing { } match self { - Typing::Any => unreachable!(), - Typing::Nullable(_) => unreachable!(), Typing::Bool => self.coerce_bool(v), Typing::Int => self.coerce_int(v), Typing::Float => self.coerce_float(v), @@ -148,6 +144,9 @@ impl Typing { Typing::NamedTuple(nt) => { todo!() } + Typing::Any => unreachable!(), + Typing::Nullable(_) => unreachable!(), + } } fn coerce_bool<'a>(&self, v: Value<'a>) -> Result> {