Skip to content

Commit

Permalink
feat(version): add const constructor (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Aug 4, 2024
1 parent fab0214 commit da8c053
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,17 @@ pub struct Version {
}

impl Version {
/// Create a [Version] with a major, minor, and patch version.
pub const fn new(major: u64, minor: u64, patch: u64) -> Self {
Self {
major,
minor,
patch,
build: Vec::new(),
pre_release: Vec::new(),
}
}

/// True if this [Version] satisfies the given [Range].
pub fn satisfies(&self, range: &Range) -> bool {
range.satisfies(self)
Expand Down

0 comments on commit da8c053

Please sign in to comment.