From 914730d7f1cb5e032cce155440bbe4f064a09533 Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Mon, 17 Feb 2025 12:13:28 +0000 Subject: [PATCH] Add inline to small functions in result module --- units/src/amount/result.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/units/src/amount/result.rs b/units/src/amount/result.rs index c0e84f6e7..645b3edde 100644 --- a/units/src/amount/result.rs +++ b/units/src/amount/result.rs @@ -27,6 +27,7 @@ impl NumOpResult { /// # Panics /// /// Panics with `msg` if the numeric result is an `Error`. + #[inline] #[track_caller] pub fn expect(self, msg: &str) -> T { match self { @@ -40,6 +41,7 @@ impl NumOpResult { /// # Panics /// /// Panics if the numeric result is an `Error`. + #[inline] #[track_caller] pub fn unwrap(self) -> T { match self { @@ -53,6 +55,7 @@ impl NumOpResult { /// # Panics /// /// Panics if the numeric result is a valid amount. + #[inline] #[track_caller] pub fn unwrap_err(self) -> NumOpError { match self { @@ -62,6 +65,7 @@ impl NumOpResult { } /// Converts this `NumOpResult` to an `Option`. + #[inline] pub fn ok(self) -> Option { match self { R::Valid(amount) => Some(amount), @@ -70,6 +74,7 @@ impl NumOpResult { } /// Converts this `NumOpResult` to a `Result`. + #[inline] #[allow(clippy::missing_errors_doc)] pub fn into_result(self) -> Result { match self { @@ -79,6 +84,7 @@ impl NumOpResult { } /// Calls `op` if the numeric result is `Valid`, otherwise returns the `Error` value of `self`. + #[inline] pub fn and_then(self, op: F) -> NumOpResult where F: FnOnce(T) -> NumOpResult, @@ -90,6 +96,7 @@ impl NumOpResult { } /// Returns `true` if the numeric result is a valid amount. + #[inline] pub fn is_valid(&self) -> bool { match self { R::Valid(_) => true, @@ -98,6 +105,7 @@ impl NumOpResult { } /// Returns `true` if the numeric result is an invalid amount. + #[inline] pub fn is_error(&self) -> bool { !self.is_valid() } } @@ -556,6 +564,7 @@ pub(in crate::amount) trait OptionExt { } impl OptionExt for Option { + #[inline] fn valid_or_error(self) -> NumOpResult { match self { Some(amount) => R::Valid(amount), @@ -565,6 +574,7 @@ impl OptionExt for Option { } impl OptionExt for Option { + #[inline] fn valid_or_error(self) -> NumOpResult { match self { Some(amount) => R::Valid(amount),