diff options
author | Nadrieril | 2020-04-05 16:49:15 +0100 |
---|---|---|
committer | Nadrieril | 2020-04-05 16:49:34 +0100 |
commit | 75c0f328c7b6d404353fd078ae12417766ef8a32 (patch) | |
tree | 032496c3df24c2ded13f465f53f0f1f1fe3cbf39 | |
parent | 118c02d330865fcbfb1f2b0028f9404d61b662d8 (diff) |
Tweaks
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | serde_dhall/src/options.rs | 23 |
2 files changed, 13 insertions, 11 deletions
@@ -169,7 +169,6 @@ same name as the corresponding test. #### [???] -- Add `serde_dhall::options` for finer control over Dhall behavior - Breaking change: reworked most of the `serde_dhall` api #### [0.4.0] diff --git a/serde_dhall/src/options.rs b/serde_dhall/src/options.rs index 0f18091..ca1e58c 100644 --- a/serde_dhall/src/options.rs +++ b/serde_dhall/src/options.rs @@ -12,11 +12,11 @@ enum Source<'a> { // Url(&'a str), } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy)] pub struct NoAnnot; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy)] pub struct ManualAnnot<'ty>(&'ty SimpleType); -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy)] pub struct StaticAnnot; pub trait HasAnnot<A> { @@ -108,7 +108,7 @@ impl<'a> Deserializer<'a, NoAnnot> { /// In many cases the Dhall type that corresponds to a Rust type can be inferred automatically. /// See the [`StaticType`] trait and the [`static_type_annotation`] method. /// - /// # Examples + /// # Example /// /// ``` /// # fn main() -> serde_dhall::Result<()> { @@ -163,7 +163,7 @@ impl<'a> Deserializer<'a, NoAnnot> { /// `T` must implement the [`StaticType`] trait. If it doesn't, you can use [`type_annotation`] /// to provide a type manually. /// - /// # Examples + /// # Example /// /// ``` /// # fn main() -> serde_dhall::Result<()> { @@ -214,7 +214,7 @@ impl<'a, A> Deserializer<'a, A> { /// /// By default, imports are enabled. /// - /// # Examples + /// # Example /// /// ``` /// # fn main() -> serde_dhall::Result<()> { @@ -272,16 +272,19 @@ impl<'a, A> Deserializer<'a, A> { /// Parses the chosen dhall value with the options provided. /// - /// # Examples + /// If you enabled static annotations, `T` is additional required to implement [`StaticType`]. /// - /// Reading from a file: /// - /// ```no_run + /// # Example + /// + /// ``` /// # fn main() -> serde_dhall::Result<()> { - /// let data = serde_dhall::from_file("foo.dhall").parse::<u64>()?; + /// let data = serde_dhall::from_str("6 * 7").parse::<u64>()?; + /// assert_eq!(data, 42) /// # Ok(()) /// # } /// ``` + /// [`StaticType`]: trait.StaticType.html pub fn parse<T>(&self) -> Result<T> where T: FromDhall + HasAnnot<A>, |