Skip to content

Commit

Permalink
Merge pull request #59 from newAM/master
Browse files Browse the repository at this point in the history
Implement Display for Version.
  • Loading branch information
a1ien authored May 4, 2021
2 parents b81cc75 + 98b3103 commit ad2bde7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ impl Version {
}
}

impl std::fmt::Display for Version {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}.{}.{}", self.major(), self.minor(), self.sub_minor())
}
}

/// Builds a value for the `bmRequestType` field of a control transfer setup packet.
///
/// The `bmRequestType` field of a USB control transfer setup packet is a bit field specifying
Expand Down Expand Up @@ -269,6 +275,11 @@ mod test {
assert_eq!(Version(12, 3, 4), Version::from_bcd(0x1234));
}

#[test]
fn version_display() {
assert_eq!(Version(2, 45, 13).to_string(), "2.45.13");
}

// request_type for direction

#[test]
Expand Down

0 comments on commit ad2bde7

Please sign in to comment.