From da8c0534b0552c12c0cafa96a4dd15190f43fbdd Mon Sep 17 00:00:00 2001 From: tottoto Date: Sun, 4 Aug 2024 14:02:13 +0900 Subject: [PATCH] feat(version): add const constructor (#13) --- src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index f0d2ef6..21aa0ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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)