diff --git a/src/fnc/type.rs b/src/fnc/type.rs index 96d1a96e..e7444192 100644 --- a/src/fnc/type.rs +++ b/src/fnc/type.rs @@ -2,6 +2,7 @@ use crate::dbs::Runtime; use crate::err::Error; use crate::sql::geometry::Geometry; use crate::sql::number::Number; +use crate::sql::table::Table; use crate::sql::thing::Thing; use crate::sql::value::Value; @@ -95,7 +96,9 @@ pub fn string(_: &Runtime, mut args: Vec) -> Result { } pub fn table(_: &Runtime, mut args: Vec) -> Result { - Ok(Value::Table(args.remove(0).as_strand().value.into())) + Ok(Value::Table(Table { + name: args.remove(0).as_strand().value, + })) } pub fn thing(_: &Runtime, mut args: Vec) -> Result { diff --git a/src/sql/table.rs b/src/sql/table.rs index e08958f6..051f19f1 100644 --- a/src/sql/table.rs +++ b/src/sql/table.rs @@ -27,22 +27,6 @@ pub struct Table { pub name: String, } -impl From for Table { - fn from(s: String) -> Self { - Table { - name: s, - } - } -} - -impl<'a> From<&'a str> for Table { - fn from(t: &str) -> Table { - Table { - name: String::from(t), - } - } -} - impl fmt::Display for Table { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", escape(&self.name, &val_char, "`")) @@ -51,7 +35,12 @@ impl fmt::Display for Table { pub fn table(i: &str) -> IResult<&str, Table> { let (i, v) = ident_raw(i)?; - Ok((i, Table::from(v))) + Ok(( + i, + Table { + name: v, + }, + )) } #[cfg(test)] @@ -66,7 +55,12 @@ mod tests { assert!(res.is_ok()); let out = res.unwrap().1; assert_eq!("test", format!("{}", out)); - assert_eq!(out, Table::from("test")); + assert_eq!( + out, + Table { + name: String::from("test"), + } + ); } #[test] @@ -76,7 +70,12 @@ mod tests { assert!(res.is_ok()); let out = res.unwrap().1; assert_eq!("test", format!("{}", out)); - assert_eq!(out, Table::from("test")); + assert_eq!( + out, + Table { + name: String::from("test"), + } + ); } #[test] @@ -86,6 +85,11 @@ mod tests { assert!(res.is_ok()); let out = res.unwrap().1; assert_eq!("test", format!("{}", out)); - assert_eq!(out, Table::from("test")); + assert_eq!( + out, + Table { + name: String::from("test"), + } + ); } }