Hyperlink the ser::Error documentation

This commit is contained in:
David Tolnay
2017-04-13 13:20:12 -07:00
parent f8e53e837d
commit 4f6518dad7
+13 -7
View File
@@ -112,18 +112,21 @@ pub use self::impossible::Impossible;
macro_rules! declare_error_trait { macro_rules! declare_error_trait {
(Error: Sized $(+ $($supertrait:ident)::+)*) => { (Error: Sized $(+ $($supertrait:ident)::+)*) => {
/// Trait used by `Serialize` implementations to generically construct /// Trait used by [`Serialize`] implementations to generically construct
/// errors belonging to the `Serializer` against which they are /// errors belonging to the [`Serializer`] against which they are
/// currently running. /// currently running.
///
/// [`Serialize`]: ../trait.Serialize.html
/// [`Serializer`]: ../trait.Serializer.html
pub trait Error: Sized $(+ $($supertrait)::+)* { pub trait Error: Sized $(+ $($supertrait)::+)* {
/// Raised when a `Serialize` implementation encounters a general /// Used when a [`Serialize`] implementation encounters any error
/// error while serializing a type. /// while serializing a type.
/// ///
/// The message should not be capitalized and should not end with a /// The message should not be capitalized and should not end with a
/// period. /// period.
/// ///
/// For example, a filesystem `Path` may refuse to serialize itself /// For example, a filesystem [`Path`] may refuse to serialize
/// if it contains invalid UTF-8 data. /// itself if it contains invalid UTF-8 data.
/// ///
/// ```rust /// ```rust
/// # struct Path; /// # struct Path;
@@ -141,12 +144,15 @@ macro_rules! declare_error_trait {
/// where S: Serializer /// where S: Serializer
/// { /// {
/// match self.to_str() { /// match self.to_str() {
/// Some(s) => s.serialize(serializer), /// Some(s) => serializer.serialize_str(s),
/// None => Err(ser::Error::custom("path contains invalid UTF-8 characters")), /// None => Err(ser::Error::custom("path contains invalid UTF-8 characters")),
/// } /// }
/// } /// }
/// } /// }
/// ``` /// ```
///
/// [`Path`]: https://doc.rust-lang.org/std/path/struct.Path.html
/// [`Serialize`]: ../trait.Serialize.html
fn custom<T>(msg: T) -> Self fn custom<T>(msg: T) -> Self
where where
T: Display; T: Display;