From 730d99adf2d4a7f222a71d687ea942545a7038fd Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 10 Apr 2019 19:55:50 +0200 Subject: Add error submodule --- dhall/src/error.rs | 3 +++ dhall/src/lib.rs | 5 +++-- dhall/src/serde.rs | 2 +- dhall/src/traits.rs | 6 +----- 4 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 dhall/src/error.rs (limited to 'dhall') diff --git a/dhall/src/error.rs b/dhall/src/error.rs new file mode 100644 index 0000000..ef8dd34 --- /dev/null +++ b/dhall/src/error.rs @@ -0,0 +1,3 @@ +// TODO +pub type Error = (); +pub type Result = std::result::Result; diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs index ababc5d..c218aeb 100644 --- a/dhall/src/lib.rs +++ b/dhall/src/lib.rs @@ -131,18 +131,19 @@ pub use crate::traits::Deserialize; pub use crate::traits::SimpleStaticType; pub use crate::traits::StaticType; pub use dhall_generator::SimpleStaticType; +pub mod error; pub mod expr; pub mod serde; pub fn from_str<'a, T: Deserialize<'a>>( s: &'a str, ty: Option<&crate::expr::Type>, -) -> crate::traits::Result { +) -> crate::error::Result { T::from_str(s, ty) } pub fn from_str_auto_type<'a, T: Deserialize<'a> + StaticType>( s: &'a str, -) -> crate::traits::Result { +) -> crate::error::Result { from_str(s, Some(&::get_static_type())) } diff --git a/dhall/src/serde.rs b/dhall/src/serde.rs index 278ea7a..4ac4f3d 100644 --- a/dhall/src/serde.rs +++ b/dhall/src/serde.rs @@ -1,6 +1,6 @@ +use crate::error::Result; use crate::expr::Type; use crate::traits::Deserialize; -use crate::traits::Result; impl<'a, T: serde::Deserialize<'a>> Deserialize<'a> for T { fn from_str(_s: &'a str, _ty: Option<&Type>) -> Result { diff --git a/dhall/src/traits.rs b/dhall/src/traits.rs index 370632e..328cbbc 100644 --- a/dhall/src/traits.rs +++ b/dhall/src/traits.rs @@ -1,11 +1,9 @@ +use crate::error::*; use crate::expr::*; use dhall_core::*; use dhall_generator::*; use std::borrow::Cow; -#[derive(Debug, Clone)] -pub enum ConversionError {} - pub trait StaticType { fn get_static_type() -> Type; } @@ -19,8 +17,6 @@ pub trait SimpleStaticType { fn get_simple_static_type() -> SimpleType; } -pub type Error = (); -pub type Result = std::result::Result; pub trait Deserialize<'a>: Sized { fn from_str(s: &'a str, ty: Option<&Type>) -> Result; -- cgit v1.2.3