summaryrefslogtreecommitdiff
path: root/serde_dhall
diff options
context:
space:
mode:
authorNadrieril2020-04-05 16:49:15 +0100
committerNadrieril2020-04-05 16:49:34 +0100
commit75c0f328c7b6d404353fd078ae12417766ef8a32 (patch)
tree032496c3df24c2ded13f465f53f0f1f1fe3cbf39 /serde_dhall
parent118c02d330865fcbfb1f2b0028f9404d61b662d8 (diff)
Tweaks
Diffstat (limited to 'serde_dhall')
-rw-r--r--serde_dhall/src/options.rs23
1 files changed, 13 insertions, 10 deletions
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>,