summaryrefslogtreecommitdiff
path: root/src/poisonable/error.rs
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2024-09-25 20:55:52 -0400
committerBotahamec <botahamec@outlook.com>2024-09-25 20:55:52 -0400
commit05b0b24acaf304d89101e9f5bea8989c495c0f44 (patch)
tree62fc78d719638dee590e37827941994453f69752 /src/poisonable/error.rs
parentcc57eea563e9c12122dd47c8b6133dab8660c1b4 (diff)
Better error implementation
Diffstat (limited to 'src/poisonable/error.rs')
-rw-r--r--src/poisonable/error.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/poisonable/error.rs b/src/poisonable/error.rs
index 98a167c..2384953 100644
--- a/src/poisonable/error.rs
+++ b/src/poisonable/error.rs
@@ -17,6 +17,28 @@ impl<Guard> fmt::Display for PoisonError<Guard> {
impl<Guard> Error for PoisonError<Guard> {}
+impl<Guard> PoisonError<Guard> {
+ #[must_use]
+ pub const fn new(guard: Guard) -> Self {
+ Self { guard }
+ }
+
+ #[must_use]
+ pub fn into_inner(self) -> Guard {
+ self.guard
+ }
+
+ #[must_use]
+ pub const fn get_ref(&self) -> &Guard {
+ &self.guard
+ }
+
+ #[must_use]
+ pub fn get_mut(&mut self) -> &mut Guard {
+ &mut self.guard
+ }
+}
+
impl<'flag, 'key, G, Key> fmt::Debug for TryLockPoisonableError<'flag, 'key, G, Key> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {