Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Display for Version #39

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vbs"
version = "0.1.3"
version = "0.1.4"
edition = "2021"
rust-version = "1.75.0"
authors = ["Espresso Systems <[email protected]>"]
Expand All @@ -12,7 +12,7 @@ license = "MIT"

[dependencies]
anyhow = "1.0"
derive_more = "0.99"
bincode = "1.3"
displaydoc = "0.2"
serde = { version = "1.0", features = ["derive"] }
serde_with = "3.4"
13 changes: 12 additions & 1 deletion src/version.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use anyhow::anyhow;
use core::fmt::Debug;
use displaydoc::Display;
use derive_more::Display;
use serde::{Deserialize, Serialize};

#[derive(Clone, Copy, Debug, Deserialize, Display, Eq, Hash, PartialEq, Serialize)]
/// Type for protocol version number
#[display(fmt = "{major}.{minor}")]
pub struct Version {
/// major version number
pub major: u16,
Expand Down Expand Up @@ -82,3 +83,13 @@ mod private {
// Implement for those same types, but no others.
impl<const MAJOR: u16, const MINOR: u16> Sealed for super::StaticVersion<MAJOR, MINOR> {}
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_version_display() {
assert_eq!("1.2", Version { major: 1, minor: 2 }.to_string());
}
}
Loading