Skip to content

Commit

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

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

* fmt

* apply review suggestions
  • Loading branch information
svyatonik authored and serban300 committed Apr 8, 2024
1 parent 198b462 commit bef330e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions bridges/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 bef330e

Please sign in to comment.