Skip to content

Commit 73eec6b

Browse files
Add a PartialEq implementation for tests
Signed-off-by: Luca Della Vedova <[email protected]>
1 parent e79f46f commit 73eec6b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

rclrs/src/dynamic_message/error.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,15 @@ impl Error for DynamicMessageError {
5151
}
5252
}
5353
}
54+
55+
impl PartialEq for DynamicMessageError {
56+
fn eq(&self, other: &Self) -> bool {
57+
if std::mem::discriminant(self) != std::mem::discriminant(other) {
58+
return false;
59+
}
60+
// TODO(luca) this is not very efficient, revisit
61+
return self.to_string() == other.to_string();
62+
}
63+
}
64+
65+
impl Eq for DynamicMessageError { }

rclrs/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::dynamic_message::DynamicMessageError;
99
use crate::{rcl_bindings::*, DeclarationError};
1010

1111
/// The main error type.
12-
#[derive(Debug)]
12+
#[derive(Debug, PartialEq, Eq)]
1313
pub enum RclrsError {
1414
/// An error originating in the `rcl` layer.
1515
RclError {

0 commit comments

Comments
 (0)