From 48bb9c03b0ace9efa33315e06c47a868e5c4ed36 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 28 Oct 2020 22:43:34 +0000 Subject: Move table of type correspondances --- serde_dhall/src/static_type.rs | 26 ++++---------------------- serde_dhall/src/value.rs | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 23 deletions(-) (limited to 'serde_dhall') diff --git a/serde_dhall/src/static_type.rs b/serde_dhall/src/static_type.rs index 7e6c27c..586cd4d 100644 --- a/serde_dhall/src/static_type.rs +++ b/serde_dhall/src/static_type.rs @@ -10,6 +10,10 @@ use crate::SimpleType; /// corresponds to them. For example, `HashMap` could correspond to multiple different /// Dhall types, e.g. `{ foo: Natural, bar: Natural }` and `{ baz: Natural }`. /// +/// See also [the table of type correspondances]. +/// +/// [the table of type correspondances]: enum.SimpleType.html#type-correspondence +/// /// # Example /// /// ```rust @@ -29,28 +33,6 @@ use crate::SimpleType; /// # Ok(()) /// # } /// ``` -/// -/// # Type correspondence -/// -/// The following Dhall types correspond to the following Rust types: -/// -/// Dhall | Rust -/// -------|------ -/// `Bool` | `bool` -/// `Natural` | `u64`, `u32`, ... -/// `Integer` | `i64`, `i32`, ... -/// `Double` | `f64`, `f32`, ... -/// `Text` | `String` -/// `List T` | `Vec` -/// `Optional T` | `Option` -/// `{ x: T, y: U }` | structs -/// `{ _1: T, _2: U }` | `(T, U)`, structs -/// `{ x: T, y: T }` | `HashMap`, structs -/// `< x: T \| y: U >` | enums -/// `Prelude.Map.Type Text T` | `HashMap`, structs -/// `T -> U` | unsupported -/// `Prelude.JSON.Type` | unsupported -/// `Prelude.Map.Type T U` | unsupported pub trait StaticType { /// Return the Dhall type that represents this type. /// diff --git a/serde_dhall/src/value.rs b/serde_dhall/src/value.rs index 50c12bd..b8ad199 100644 --- a/serde_dhall/src/value.rs +++ b/serde_dhall/src/value.rs @@ -124,6 +124,28 @@ pub enum SimpleValue { /// [`StaticType`]: trait.StaticType.html /// [`Deserializer::static_type_annotation`]: options/struct.Deserializer.html#method.static_type_annotation /// +/// # Type correspondence +/// +/// The following Dhall types correspond to the following Rust types: +/// +/// Dhall | Rust +/// -------|------ +/// `Bool` | `bool` +/// `Natural` | `u64`, `u32`, ... +/// `Integer` | `i64`, `i32`, ... +/// `Double` | `f64`, `f32`, ... +/// `Text` | `String` +/// `List T` | `Vec` +/// `Optional T` | `Option` +/// `{ x: T, y: U }` | structs +/// `{ _1: T, _2: U }` | `(T, U)`, structs +/// `{ x: T, y: T }` | `HashMap`, structs +/// `< x: T \| y: U >` | enums +/// `Prelude.Map.Type Text T` | `HashMap`, structs +/// `T -> U` | unsupported +/// `Prelude.JSON.Type` | unsupported +/// `Prelude.Map.Type T U` | unsupported +/// /// # Examples /// /// ```rust @@ -159,7 +181,6 @@ pub enum SimpleValue { /// # Ok(()) /// # } /// ``` -/// #[derive(Debug, Clone, PartialEq, Eq)] pub enum SimpleType { /// Corresponds to the Dhall type `Bool` -- cgit v1.2.3