diff options
-rw-r--r-- | serde_dhall/src/deserialize.rs | 1 | ||||
-rw-r--r-- | serde_dhall/src/lib.rs | 22 | ||||
-rw-r--r-- | serde_dhall/src/options/de.rs | 48 | ||||
-rw-r--r-- | serde_dhall/src/options/ser.rs | 36 | ||||
-rw-r--r-- | serde_dhall/src/static_type.rs | 2 | ||||
-rw-r--r-- | serde_dhall/src/value.rs | 10 |
6 files changed, 52 insertions, 67 deletions
diff --git a/serde_dhall/src/deserialize.rs b/serde_dhall/src/deserialize.rs index 0e518ea..3fb06f9 100644 --- a/serde_dhall/src/deserialize.rs +++ b/serde_dhall/src/deserialize.rs @@ -84,7 +84,6 @@ impl<T> Sealed for T where T: serde::de::DeserializeOwned {} /// # } /// ``` /// -/// [`SimpleValue`]: enum.SimpleValue.html pub fn from_simple_value<T>(v: SimpleValue) -> crate::Result<T> where T: serde::de::DeserializeOwned, diff --git a/serde_dhall/src/lib.rs b/serde_dhall/src/lib.rs index 01d036b..cd6affd 100644 --- a/serde_dhall/src/lib.rs +++ b/serde_dhall/src/lib.rs @@ -16,8 +16,8 @@ //! //! ## Deserialization (reading) //! -//! The entrypoint for deserialization is the [`from_str`](fn.from_str.html) function. It reads a -//! string containing a Dhall expression and deserializes it into any serde-compatible type. +//! The entrypoint for deserialization is the [`from_str()`] function. It reads a string containing +//! a Dhall expression and deserializes it into any serde-compatible type. //! //! This could mean a common Rust type like `HashMap`: //! @@ -66,8 +66,8 @@ //! //! ## Serialization (writing) //! -//! The entrypoint for serialization is the [`serialize`](fn.serialize.html) function. It takes a -//! serde-compatible type value and serializes it to a string containing a Dhall expression. +//! The entrypoint for serialization is the [`serialize()`] function. It takes a serde-compatible +//! type value and serializes it to a string containing a Dhall expression. //! //! This could mean a common Rust type like `HashMap`: //! @@ -116,9 +116,9 @@ //! # Replacing `serde_json` or `serde_yaml` //! //! If you used to consume JSON or YAML, you only need to replace [`serde_json::from_str`] or -//! [`serde_yaml::from_str`] with [`serde_dhall::from_str(…).parse()`](fn.from_str.html). +//! [`serde_yaml::from_str`] with [`serde_dhall::from_str(…).parse()`](from_str()). //! If you used to produce JSON or YAML, you only need to replace [`serde_json::to_string`] or -//! [`serde_yaml::to_string`] with [`serde_dhall::serialize(…).to_string()`](fn.serialize.html). +//! [`serde_yaml::to_string`] with [`serde_dhall::serialize(…).to_string()`](serialize()). //! //! [`serde_json::from_str`]: https://docs.serde.rs/serde_json/fn.from_str.html //! [`serde_yaml::from_str`]: https://docs.serde.rs/serde_yaml/fn.from_str.html @@ -142,8 +142,8 @@ //! explicitly. //! //! There are two ways to provide a type in this way: you can provide it manually or you can let -//! Rust infer it for you. To let Rust infer the appropriate Dhall type, use the -//! [StaticType](trait.StaticType.html) trait. +//! Rust infer it for you. To let Rust infer the appropriate Dhall type, use the [`StaticType`] +//! trait. //! //! ```rust //! # fn main() -> serde_dhall::Result<()> { @@ -200,8 +200,8 @@ //! # } //! ``` //! -//! To provide a type manually, you need a [`SimpleType`](enum.SimpleType.html) value. You -//! can parse it from some Dhall text like you would parse any other value. +//! To provide a type manually, you need a [`SimpleType`] value. You can parse it from some Dhall +//! text like you would parse any other value. //! //! ```rust //! # fn main() -> serde_dhall::Result<()> { @@ -249,8 +249,6 @@ //! If you need more control over the process of reading Dhall values, e.g. disabling //! imports, see the [`Deserializer`] methods. //! -//! [`Deserializer`]: struct.Deserializer.html -//! [`SimpleValue`]: enum.SimpleValue.html //! [dhall]: https://dhall-lang.org/ //! [serde]: https://docs.serde.rs/serde/ //! [serde::Deserialize]: https://docs.serde.rs/serde/trait.Deserialize.html diff --git a/serde_dhall/src/options/de.rs b/serde_dhall/src/options/de.rs index 30846a2..103f161 100644 --- a/serde_dhall/src/options/de.rs +++ b/serde_dhall/src/options/de.rs @@ -19,15 +19,12 @@ enum Source<'a> { /// This builder exposes the ability to configure how a value is deserialized and what operations /// are permitted during evaluation. /// -/// Generally speaking, when using [`Deserializer`], you'll create it with [`from_str`] or [`from_file`], then -/// chain calls to methods to set each option, then call [`parse`]. This will give you a -/// [`Result<T>`] where `T` is a deserializable type of your choice. +/// Generally speaking, when using [`Deserializer`], you'll create it with [`from_str()`] or +/// [`from_file()`], then chain calls to methods to set each option, then call [`parse()`]. This +/// will give you a [`Result<T>`] where `T` is a deserializable type of your choice. /// -/// [`Deserializer`]: struct.Deserializer.html -/// [`from_str`]: fn.from_str.html -/// [`from_file`]: fn.from_file.html -/// [`parse`]: struct.Deserializer.html#method.parse -/// [`Result<T>`]: type.Result.html +/// [`parse()`]: Deserializer::parse() +/// [`Result<T>`]: Result /// /// # Examples /// @@ -91,7 +88,7 @@ impl<'a> Deserializer<'a, NoAnnot> { /// Ensures that the parsed value matches the provided type. /// /// 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 for that. + /// See the [`StaticType`] trait and the [`static_type_annotation()`] method for that. /// /// # Example /// @@ -124,8 +121,8 @@ impl<'a> Deserializer<'a, NoAnnot> { /// # } /// ``` /// - /// [`static_type_annotation`]: struct.Deserializer.html#method.static_type_annotation - /// [`StaticType`]: trait.StaticType.html + /// [`StaticType`]: crate::StaticType + /// [`static_type_annotation()`]: Deserializer::static_type_annotation() pub fn type_annotation<'ty>( self, ty: &'ty SimpleType, @@ -139,8 +136,8 @@ impl<'a> Deserializer<'a, NoAnnot> { /// Ensures that the parsed value matches the type of `T`. /// - /// `T` must implement the [`StaticType`] trait. If it doesn't, you can use [`type_annotation`] - /// to provide a type manually. + /// `T` must implement the [`StaticType`] trait. If it doesn't, you can use + /// [`type_annotation()`] to provide a type manually. /// /// # Example /// @@ -177,8 +174,8 @@ impl<'a> Deserializer<'a, NoAnnot> { /// # } /// ``` /// - /// [`type_annotation`]: struct.Deserializer.html#method.type_annotation - /// [`StaticType`]: trait.StaticType.html + /// [`StaticType`]: crate::StaticType + /// [`type_annotation()`]: Deserializer::type_annotation() pub fn static_type_annotation(self) -> Deserializer<'a, StaticAnnot> { Deserializer { annot: StaticAnnot, @@ -210,9 +207,6 @@ impl<'a, A> Deserializer<'a, A> { /// # Ok(()) /// # } /// ``` - /// - /// [`static_type_annotation`]: struct.Deserializer.html#method.static_type_annotation - /// [`StaticType`]: trait.StaticType.html pub fn imports(self, imports: bool) -> Self { Deserializer { allow_imports: imports, @@ -271,7 +265,8 @@ impl<'a, A> Deserializer<'a, A> { /// # Ok(()) /// # } /// ``` - /// [`StaticType`]: trait.StaticType.html + /// + /// [`StaticType`]: crate::StaticType pub fn parse<T>(&self) -> Result<T> where A: TypeAnnot, @@ -287,7 +282,7 @@ impl<'a, A> Deserializer<'a, A> { /// Deserialize a value from a string of Dhall text. /// -/// This returns a [`Deserializer`] object. Call the [`parse`] method to get the deserialized +/// This returns a [`Deserializer`] object. Call the [`parse()`] method to get the deserialized /// value, or use other [`Deserializer`] methods to control the deserialization process. /// /// Imports will be resolved relative to the current directory. @@ -317,15 +312,14 @@ impl<'a, A> Deserializer<'a, A> { /// # } /// ``` /// -/// [`Deserializer`]: struct.Deserializer.html -/// [`parse`]: struct.Deserializer.html#method.parse +/// [`parse()`]: Deserializer::parse() pub fn from_str(s: &str) -> Deserializer<'_, NoAnnot> { Deserializer::from_str(s) } /// Deserialize a value from a Dhall file. /// -/// This returns a [`Deserializer`] object. Call the [`parse`] method to get the deserialized +/// This returns a [`Deserializer`] object. Call the [`parse()`] method to get the deserialized /// value, or use other [`Deserializer`] methods to control the deserialization process. /// /// Imports will be resolved relative to the provided file's path. @@ -349,8 +343,7 @@ pub fn from_str(s: &str) -> Deserializer<'_, NoAnnot> { /// # } /// ``` /// -/// [`Deserializer`]: struct.Deserializer.html -/// [`parse`]: struct.Deserializer.html#method.parse +/// [`parse()`]: Deserializer::parse() pub fn from_file<'a, P: AsRef<Path>>(path: P) -> Deserializer<'a, NoAnnot> { Deserializer::from_file(path) } @@ -359,7 +352,7 @@ pub fn from_file<'a, P: AsRef<Path>>(path: P) -> Deserializer<'a, NoAnnot> { /// the Dhall standard specification and is mostly used for caching expressions. Using the format /// is not recommended because errors won't have a file to refer to and thus will be hard to fix. /// -/// This returns a [`Deserializer`] object. Call the [`parse`] method to get the deserialized +/// This returns a [`Deserializer`] object. Call the [`parse()`] method to get the deserialized /// value, or use other [`Deserializer`] methods to control the deserialization process. /// /// Imports will be resolved relative to the provided file's path. @@ -383,8 +376,7 @@ pub fn from_file<'a, P: AsRef<Path>>(path: P) -> Deserializer<'a, NoAnnot> { /// # } /// ``` /// -/// [`Deserializer`]: struct.Deserializer.html -/// [`parse`]: struct.Deserializer.html#method.parse +/// [`parse()`]: Deserializer::parse() pub fn from_binary_file<'a, P: AsRef<Path>>( path: P, ) -> Deserializer<'a, NoAnnot> { diff --git a/serde_dhall/src/options/ser.rs b/serde_dhall/src/options/ser.rs index d74beb0..d2c173b 100644 --- a/serde_dhall/src/options/ser.rs +++ b/serde_dhall/src/options/ser.rs @@ -6,17 +6,14 @@ use crate::{Result, SimpleType, ToDhall}; /// This builder exposes the ability to configure how a value is serialized, and to set type /// annotations. /// -/// When using [`Serializer`], you'll create it with [`serialize`], then chain calls to methods to -/// set each option, then call [`to_string`]. This will give you a [`Result<String>`] containing -/// the input serialized to Dhall. +/// When using [`Serializer`], you'll create it with [`serialize()`], then chain calls to methods +/// to set each option, then call [`to_string()`]. This will give you a [`Result`] containing the +/// input serialized to Dhall. /// /// Note that if you do not provide a type annotation, some values may not be convertible to Dhall, /// like empty lists or enums. /// -/// [`Serializer`]: struct.Serializer.html -/// [`serialize`]: fn.serialize.html -/// [`to_string`]: struct.Serializer.html#method.to_string -/// [`Result<String>`]: type.Result.html +/// [`to_string()`]: Serializer::to_string() /// /// # Examples /// @@ -56,7 +53,7 @@ impl<'a, T> Serializer<'a, T, NoAnnot> { /// unions. /// /// 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 for that. + /// See the [`StaticType`] trait and the [`static_type_annotation()`] method for that. /// /// # Example /// @@ -83,8 +80,8 @@ impl<'a, T> Serializer<'a, T, NoAnnot> { /// # } /// ``` /// - /// [`static_type_annotation`]: struct.Serializer.html#method.static_type_annotation - /// [`StaticType`]: trait.StaticType.html + /// [`StaticType`]: crate::StaticType + /// [`static_type_annotation()`]: Serializer::static_type_annotation() pub fn type_annotation<'ty>( self, ty: &'ty SimpleType, @@ -98,7 +95,7 @@ impl<'a, T> Serializer<'a, T, NoAnnot> { /// Uses the type of `T` in the serialization process. This will be used when Dhall needs it, /// like for empty lists or for unions. /// - /// `T` must implement the [`StaticType`] trait. If it doesn't, you can use [`type_annotation`] + /// `T` must implement the [`StaticType`] trait. If it doesn't, you can use [`type_annotation()`] /// /// # Example /// @@ -124,8 +121,8 @@ impl<'a, T> Serializer<'a, T, NoAnnot> { /// # } /// ``` /// - /// [`type_annotation`]: struct.Serializer.html#method.type_annotation - /// [`StaticType`]: trait.StaticType.html + /// [`StaticType`]: crate::StaticType + /// [`type_annotation()`]: Serializer::type_annotation() pub fn static_type_annotation(self) -> Serializer<'a, T, StaticAnnot> { Serializer { annot: StaticAnnot, @@ -158,7 +155,7 @@ where /// # } /// ``` /// - /// [`StaticType`]: trait.StaticType.html + /// [`StaticType`]: crate::StaticType pub fn to_string(&self) -> Result<String> where T: ToDhall + HasAnnot<A>, @@ -170,11 +167,11 @@ where /// Serialize a value to a string of Dhall text. /// -/// This returns a [`Serializer`] object. Call the [`to_string`] method to get the serialized +/// This returns a [`Serializer`] object. Call the [`to_string()`] method to get the serialized /// value, or use other [`Serializer`] methods to control the serialization process. /// /// In order to process certain values (like unions or empty lists) correctly, it is necessary to -/// add a type annotation (with [`static_type_annotation`] or [`type_annotation`]). +/// add a type annotation (with [`static_type_annotation()`] or [`type_annotation()`]). /// /// # Examples /// @@ -219,10 +216,9 @@ where /// # } /// ``` /// -/// [`Serializer`]: struct.Serializer.html -/// [`type_annotation`]: struct.Serializer.html#method.type_annotation -/// [`static_type_annotation`]: struct.Serializer.html#method.static_type_annotation -/// [`to_string`]: struct.Serializer.html#method.to_string +/// [`type_annotation()`]: Serializer::type_annotation() +/// [`static_type_annotation()`]: Serializer::static_type_annotation() +/// [`to_string()`]: Serializer::to_string() pub fn serialize<T>(data: &T) -> Serializer<'_, T, NoAnnot> where T: ToDhall, diff --git a/serde_dhall/src/static_type.rs b/serde_dhall/src/static_type.rs index 586cd4d..31c93a6 100644 --- a/serde_dhall/src/static_type.rs +++ b/serde_dhall/src/static_type.rs @@ -12,7 +12,7 @@ use crate::SimpleType; /// /// See also [the table of type correspondances]. /// -/// [the table of type correspondances]: enum.SimpleType.html#type-correspondence +/// [the table of type correspondances]: SimpleType#type-correspondence /// /// # Example /// diff --git a/serde_dhall/src/value.rs b/serde_dhall/src/value.rs index b259c4b..df81a85 100644 --- a/serde_dhall/src/value.rs +++ b/serde_dhall/src/value.rs @@ -93,9 +93,9 @@ pub struct Value { /// # } /// ``` /// -/// [`from_str()`]: fn.from_str.html -/// [`from_file()`]: fn.from_file.html -/// [`from_simple_value()`]: fn.from_simple_value.html +/// [`from_str()`]: crate::from_str() +/// [`from_file()`]: crate::from_file() +/// [`from_simple_value()`]: crate::from_simple_value() #[derive(Debug, Clone, PartialEq, Eq)] pub enum SimpleValue { /// Numbers and booleans - `True`, `1`, `+2`, `3.24` @@ -124,8 +124,8 @@ pub enum SimpleValue { /// [`Deserializer::static_type_annotation`]. If you need to supply a `SimpleType` manually, you /// can either deserialize it like any other Dhall value, or construct it manually. /// -/// [`StaticType`]: trait.StaticType.html -/// [`Deserializer::static_type_annotation`]: options/struct.Deserializer.html#method.static_type_annotation +/// [`Deserializer::static_type_annotation`]: crate::Deserializer::static_type_annotation() +/// [`StaticType`]: crate::StaticType /// /// # Type correspondence /// |