From 1452a4186a1eef30c85fff05d8c9788a9b57d52d Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Wed, 8 Sep 2021 16:12:53 -0400 Subject: [PATCH] tamer: convert: Add missing method-level docs --- tamer/src/convert.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tamer/src/convert.rs b/tamer/src/convert.rs index b2f830a1..00fa0561 100644 --- a/tamer/src/convert.rs +++ b/tamer/src/convert.rs @@ -55,10 +55,21 @@ pub trait ExpectFrom: TryFrom where >::Error: Debug, { + /// Attempt to convert `value` using `T::try_from`, + /// causing a panic with the given `msg` on failure. + /// + /// Panics + /// ====== + /// Causes a panic on failure. fn expect_from(value: T, msg: &str) -> T { T::try_from(value).expect(msg) } + /// Attempt to convert and unwrap `value` using `T::try_from`. + /// + /// Panics + /// ====== + /// Causes a panic on failure. fn unwrap_from(value: T) -> T { T::try_from(value).unwrap() } @@ -85,10 +96,21 @@ pub trait ExpectInto: TryInto where >::Error: Debug, { + /// Attempt to convert a value using `self.try_into()`, + /// causing a panic with the given `msg` on failure. + /// + /// Panics + /// ====== + /// Causes a panic on failure. fn expect_into(self, msg: &str) -> T { self.try_into().expect(msg) } + /// Attempt to convert and unwrap a value using `self.try_into()`. + /// + /// Panics + /// ====== + /// Causes a panic on failure. fn unwrap_into(self) -> T { self.try_into().unwrap() }