Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 777aee0

Browse files
committed
error: add convenient factory method to_err_without_payload
1 parent 0261368 commit 777aee0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎uefi/src/result/error.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,19 @@ impl<Data: Debug> Display for Error<Data> {
5454
}
5555
}
5656

57+
impl<Data: Debug> Error<Data> {
58+
/// Transforms the generic payload of an error to `()`. This is useful if
59+
/// you want
60+
/// - to retain the erroneous status code,
61+
/// - do not care about the payload, and
62+
/// - refrain from generic type complexity in a higher API level.
63+
pub fn to_err_without_payload(&self) -> Error<()> {
64+
Error {
65+
status: self.status,
66+
data: (),
67+
}
68+
}
69+
}
70+
5771
#[cfg(feature = "unstable")]
5872
impl<Data: Debug> core::error::Error for Error<Data> {}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /