concurrent_intrusive_collections/
error.rs1use std::fmt;
2
3pub enum PushError<T> {
5 Closed(Box<T>),
7}
8
9impl<T> PushError<T> {
10 pub fn into_inner(self) -> Box<T> {
12 match self {
13 Self::Closed(node) => node,
14 }
15 }
16}
17
18impl<T> fmt::Debug for PushError<T> {
19 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20 match self {
21 Self::Closed(node) => f
22 .debug_tuple("Closed")
23 .field(&(node.as_ref() as *const T))
24 .finish(),
25 }
26 }
27}
28
29impl<T> fmt::Display for PushError<T> {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 f.write_str("collection is closed")
32 }
33}
34
35impl<T> std::error::Error for PushError<T> {}
36
37#[derive(Debug, Clone, Copy, PartialEq, Eq)]
39pub enum PopError {
40 Empty,
45 Closed,
47}
48
49impl fmt::Display for PopError {
50 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
51 f.write_str(match self {
52 Self::Empty => "collection is empty",
53 Self::Closed => "collection is closed and empty",
54 })
55 }
56}
57
58impl std::error::Error for PopError {}