summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril2019-04-10 19:55:50 +0200
committerNadrieril2019-04-10 20:01:04 +0200
commit730d99adf2d4a7f222a71d687ea942545a7038fd (patch)
tree756444c6bd445f10e338c6992aa7f781466f588a
parent838f6c0a25d4024ee5f32ddde915fdd2f759018d (diff)
Add error submodule
-rw-r--r--dhall/src/error.rs3
-rw-r--r--dhall/src/lib.rs5
-rw-r--r--dhall/src/serde.rs2
-rw-r--r--dhall/src/traits.rs6
4 files changed, 8 insertions, 8 deletions
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<T> = std::result::Result<T, Error>;
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<T> {
+) -> crate::error::Result<T> {
T::from_str(s, ty)
}
pub fn from_str_auto_type<'a, T: Deserialize<'a> + StaticType>(
s: &'a str,
-) -> crate::traits::Result<T> {
+) -> crate::error::Result<T> {
from_str(s, Some(&<T as StaticType>::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<Self> {
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<T> = std::result::Result<T, Error>;
pub trait Deserialize<'a>: Sized {
fn from_str(s: &'a str, ty: Option<&Type>) -> Result<Self>;