diff options
Diffstat (limited to 'dhall/src/traits')
-rw-r--r-- | dhall/src/traits/deserialize.rs | 10 | ||||
-rw-r--r-- | dhall/src/traits/dynamic_type.rs | 16 | ||||
-rw-r--r-- | dhall/src/traits/static_type.rs | 40 |
3 files changed, 33 insertions, 33 deletions
diff --git a/dhall/src/traits/deserialize.rs b/dhall/src/traits/deserialize.rs index 99ca5ee..e3ff2d5 100644 --- a/dhall/src/traits/deserialize.rs +++ b/dhall/src/traits/deserialize.rs @@ -12,7 +12,7 @@ pub trait Deserialize<'de>: Sized { fn from_str(s: &'de str, ty: Option<&Type>) -> Result<Self>; } -impl<'de: 'a, 'a> Deserialize<'de> for Parsed<'a> { +impl<'de> Deserialize<'de> for Parsed { /// Simply parses the provided string. Ignores the /// provided type. fn from_str(s: &'de str, _: Option<&Type>) -> Result<Self> { @@ -20,7 +20,7 @@ impl<'de: 'a, 'a> Deserialize<'de> for Parsed<'a> { } } -impl<'de: 'a, 'a> Deserialize<'de> for Resolved<'a> { +impl<'de> Deserialize<'de> for Resolved { /// Parses and resolves the provided string. Ignores the /// provided type. fn from_str(s: &'de str, ty: Option<&Type>) -> Result<Self> { @@ -28,7 +28,7 @@ impl<'de: 'a, 'a> Deserialize<'de> for Resolved<'a> { } } -impl<'de: 'a, 'a> Deserialize<'de> for Typed<'a> { +impl<'de> Deserialize<'de> for Typed { /// Parses, resolves and typechecks the provided string. fn from_str(s: &'de str, ty: Option<&Type>) -> Result<Self> { let resolved = Resolved::from_str(s, ty)?; @@ -39,14 +39,14 @@ impl<'de: 'a, 'a> Deserialize<'de> for Typed<'a> { } } -impl<'de: 'a, 'a> Deserialize<'de> for Normalized<'a> { +impl<'de> Deserialize<'de> for Normalized { /// Parses, resolves, typechecks and normalizes the provided string. fn from_str(s: &'de str, ty: Option<&Type>) -> Result<Self> { Ok(Typed::from_str(s, ty)?.normalize()) } } -impl<'de: 'a, 'a> Deserialize<'de> for Type<'a> { +impl<'de> Deserialize<'de> for Type { fn from_str(s: &'de str, ty: Option<&Type>) -> Result<Self> { Ok(Normalized::from_str(s, ty)?.to_type()) } diff --git a/dhall/src/traits/dynamic_type.rs b/dhall/src/traits/dynamic_type.rs index b8f6f6d..858642e 100644 --- a/dhall/src/traits/dynamic_type.rs +++ b/dhall/src/traits/dynamic_type.rs @@ -7,29 +7,29 @@ use dhall_syntax::{Const, ExprF}; use std::borrow::Cow; pub trait DynamicType { - fn get_type<'a>(&'a self) -> Result<Cow<'a, Type<'static>>, TypeError>; + fn get_type<'a>(&'a self) -> Result<Cow<'a, Type>, TypeError>; } impl<T: StaticType> DynamicType for T { - fn get_type<'a>(&'a self) -> Result<Cow<'a, Type<'static>>, TypeError> { + fn get_type<'a>(&'a self) -> Result<Cow<'a, Type>, TypeError> { Ok(Cow::Owned(T::get_static_type())) } } -impl<'a> DynamicType for Type<'a> { - fn get_type(&self) -> Result<Cow<'_, Type<'static>>, TypeError> { +impl DynamicType for Type { + fn get_type(&self) -> Result<Cow<'_, Type>, TypeError> { self.get_type() } } -impl<'a> DynamicType for Normalized<'a> { - fn get_type(&self) -> Result<Cow<'_, Type<'static>>, TypeError> { +impl DynamicType for Normalized { + fn get_type(&self) -> Result<Cow<'_, Type>, TypeError> { self.0.get_type() } } -impl<'a> DynamicType for Typed<'a> { - fn get_type(&self) -> Result<Cow<'_, Type<'static>>, TypeError> { +impl DynamicType for Typed { + fn get_type(&self) -> Result<Cow<'_, Type>, TypeError> { self.0.get_type() } } diff --git a/dhall/src/traits/static_type.rs b/dhall/src/traits/static_type.rs index 1255d1c..f90b8df 100644 --- a/dhall/src/traits/static_type.rs +++ b/dhall/src/traits/static_type.rs @@ -11,7 +11,7 @@ use dhall_syntax::*; /// For now the only interesting impl is [SimpleType] itself, who /// has a statically-known type which is not itself a [SimpleType]. pub trait StaticType { - fn get_static_type() -> Type<'static>; + fn get_static_type() -> Type; } /// A Rust type that can be represented as a Dhall type. @@ -29,15 +29,15 @@ pub trait StaticType { /// The `Simple` in `SimpleStaticType` indicates that the returned type is /// a [SimpleType]. pub trait SimpleStaticType { - fn get_simple_static_type<'a>() -> SimpleType<'a>; + fn get_simple_static_type() -> SimpleType; } -fn mktype<'a>(x: SubExpr<X, X>) -> SimpleType<'a> { +fn mktype(x: SubExpr<X, X>) -> SimpleType { x.into() } impl<T: SimpleStaticType> StaticType for T { - fn get_static_type() -> Type<'static> { + fn get_static_type() -> Type { crate::expr::Normalized::from_thunk_and_type( crate::normalize::Thunk::from_normalized_expr( T::get_simple_static_type().into(), @@ -48,64 +48,64 @@ impl<T: SimpleStaticType> StaticType for T { } } -impl<'a> StaticType for SimpleType<'a> { +impl StaticType for SimpleType { /// By definition, a [SimpleType] has type `Type`. /// This returns the Dhall expression `Type` - fn get_static_type() -> Type<'static> { + fn get_static_type() -> Type { Type::const_type() } } impl SimpleStaticType for bool { - fn get_simple_static_type<'a>() -> SimpleType<'a> { + fn get_simple_static_type() -> SimpleType { mktype(dhall::subexpr!(Bool)) } } impl SimpleStaticType for Natural { - fn get_simple_static_type<'a>() -> SimpleType<'a> { + fn get_simple_static_type() -> SimpleType { mktype(dhall::subexpr!(Natural)) } } impl SimpleStaticType for u32 { - fn get_simple_static_type<'a>() -> SimpleType<'a> { + fn get_simple_static_type() -> SimpleType { mktype(dhall::subexpr!(Natural)) } } impl SimpleStaticType for u64 { - fn get_simple_static_type<'a>() -> SimpleType<'a> { + fn get_simple_static_type() -> SimpleType { mktype(dhall::subexpr!(Natural)) } } impl SimpleStaticType for Integer { - fn get_simple_static_type<'a>() -> SimpleType<'a> { + fn get_simple_static_type() -> SimpleType { mktype(dhall::subexpr!(Integer)) } } impl SimpleStaticType for i32 { - fn get_simple_static_type<'a>() -> SimpleType<'a> { + fn get_simple_static_type() -> SimpleType { mktype(dhall::subexpr!(Integer)) } } impl SimpleStaticType for i64 { - fn get_simple_static_type<'a>() -> SimpleType<'a> { + fn get_simple_static_type() -> SimpleType { mktype(dhall::subexpr!(Integer)) } } impl SimpleStaticType for String { - fn get_simple_static_type<'a>() -> SimpleType<'a> { + fn get_simple_static_type() -> SimpleType { mktype(dhall::subexpr!(Text)) } } impl<A: SimpleStaticType, B: SimpleStaticType> SimpleStaticType for (A, B) { - fn get_simple_static_type<'a>() -> SimpleType<'a> { + fn get_simple_static_type() -> SimpleType { let ta: SubExpr<_, _> = A::get_simple_static_type().into(); let tb: SubExpr<_, _> = B::get_simple_static_type().into(); mktype(dhall::subexpr!({ _1: ta, _2: tb })) @@ -113,27 +113,27 @@ impl<A: SimpleStaticType, B: SimpleStaticType> SimpleStaticType for (A, B) { } impl<T: SimpleStaticType> SimpleStaticType for Option<T> { - fn get_simple_static_type<'a>() -> SimpleType<'a> { + fn get_simple_static_type() -> SimpleType { let t: SubExpr<_, _> = T::get_simple_static_type().into(); mktype(dhall::subexpr!(Optional t)) } } impl<T: SimpleStaticType> SimpleStaticType for Vec<T> { - fn get_simple_static_type<'a>() -> SimpleType<'a> { + fn get_simple_static_type() -> SimpleType { let t: SubExpr<_, _> = T::get_simple_static_type().into(); mktype(dhall::subexpr!(List t)) } } impl<'a, T: SimpleStaticType> SimpleStaticType for &'a T { - fn get_simple_static_type<'b>() -> SimpleType<'b> { + fn get_simple_static_type() -> SimpleType { T::get_simple_static_type() } } impl<T> SimpleStaticType for std::marker::PhantomData<T> { - fn get_simple_static_type<'a>() -> SimpleType<'a> { + fn get_simple_static_type() -> SimpleType { mktype(dhall::subexpr!({})) } } @@ -141,7 +141,7 @@ impl<T> SimpleStaticType for std::marker::PhantomData<T> { impl<T: SimpleStaticType, E: SimpleStaticType> SimpleStaticType for std::result::Result<T, E> { - fn get_simple_static_type<'a>() -> SimpleType<'a> { + fn get_simple_static_type() -> SimpleType { let tt: SubExpr<_, _> = T::get_simple_static_type().into(); let te: SubExpr<_, _> = E::get_simple_static_type().into(); mktype(dhall::subexpr!(< Ok: tt | Err: te>)) |