github_workflows_update/
version.rs1use std::fmt;
9
10use lenient_semver;
11use semver;
12
13#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Default, Hash)]
15pub struct Version {
16 pub version: Option<semver::Version>,
18 pub string: String,
20}
21
22impl Version {
23 pub fn new(s: &str) -> Option<Version> {
24 Some(Version {
25 version: lenient_semver::parse(s).ok(),
26 string: String::from(s),
27 })
28 }
29}
30
31impl fmt::Display for Version {
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 write!(f, "{}", self.string)
34 }
35}