Skip to content

Commit

Permalink
Make debug display of LaneId compatible with its previous version (#1740
Browse files Browse the repository at this point in the history
)

* make {:?} of LaneId compatible with its previous version

* fmt

* apply review suggestions
  • Loading branch information
svyatonik authored Dec 30, 2022
1 parent 221e4e8 commit c7b6bae
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions primitives/messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,16 @@ impl OperatingMode for MessagesOperatingMode {

/// Lane id which implements `TypeId`.
#[derive(
Clone,
Copy,
Decode,
Default,
Encode,
Eq,
Ord,
PartialOrd,
PartialEq,
RuntimeDebug,
TypeInfo,
MaxEncodedLen,
Clone, Copy, Decode, Default, Encode, Eq, Ord, PartialOrd, PartialEq, TypeInfo, MaxEncodedLen,
)]
pub struct LaneId(pub [u8; 4]);

impl core::fmt::Debug for LaneId {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
self.0.fmt(fmt)
}
}

impl AsRef<[u8]> for LaneId {
fn as_ref(&self) -> &[u8] {
&self.0
Expand Down Expand Up @@ -458,4 +453,9 @@ mod tests {
assert!(delivered_messages.contains_message(150));
assert!(!delivered_messages.contains_message(151));
}

#[test]
fn lane_id_debug_format_matches_inner_array_format() {
assert_eq!(format!("{:?}", LaneId([0, 0, 0, 0])), format!("{:?}", [0, 0, 0, 0]),);
}
}

0 comments on commit c7b6bae

Please sign in to comment.