From b3a59407812b94a13fd83bf7fec36aac526359a1 Mon Sep 17 00:00:00 2001 From: Botahamec Date: Sun, 23 Oct 2022 13:39:58 -0400 Subject: Updated docs --- src/result.rs | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'src/result.rs') diff --git a/src/result.rs b/src/result.rs index 9f1bb89..2b8921c 100644 --- a/src/result.rs +++ b/src/result.rs @@ -13,6 +13,44 @@ use sealed::Sealed; #[cfg(feature = "std")] pub trait ResultErrorExt: Sealed { /// Converts `Result` to `Result`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use exun::*; + /// use core::fmt::Error; + /// + /// let res: Result = Err(Error); + /// let res: Result = res.unexpect(); + /// ``` + /// + /// Use with the try operator + /// + /// ``` + /// use exun::*; + /// use core::fmt::Error; + /// + /// fn foo() -> Result { + /// let res: Result = Err(Error); + /// Ok(res.unexpect()?) + /// } + /// ``` + /// + /// Use with the try operator and [`Exun`] + /// + /// ``` + /// use exun::*; + /// use core::fmt::Error; + /// + /// fn foo() -> Result> { + /// let res: Result = Err(Error); + /// Ok(res.unexpect()?) + /// } + /// ``` + /// + /// [`Exun`]: `crate::Exun` #[allow(clippy::missing_errors_doc)] fn unexpect(self) -> Result; } @@ -29,6 +67,41 @@ pub trait ResultMsgExt: Sealed { /// /// This is provided for compatibility with `no_std`. If your type /// implements [`Error`], then you should prefer that instead. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use exun::*; + /// + /// let res: Result = Err("failure"); + /// let res: Result = res.unexpect_msg(); + /// ``` + /// + /// Use with the try operator + /// + /// ``` + /// use exun::*; + /// + /// fn foo() -> Result { + /// let res: Result = Err("failure"); + /// Ok(res.unexpect_msg()?) + /// } + /// ``` + /// + /// Use with the try operator and [`Exun`] + /// + /// ``` + /// use exun::*; + /// + /// fn foo() -> Result> { + /// let res: Result = Err("failure"); + /// Ok(res.unexpect_msg()?) + /// } + /// ``` + /// + /// [`Exun`]: `crate::Exun` #[allow(clippy::missing_errors_doc)] fn unexpect_msg(self) -> Result; } -- cgit v1.2.3