Skip to content

Commit 05fe57e

Browse files
committed
error: add convenient factory method to_err_without_payload
1 parent 2be151b commit 05fe57e

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)