Skip to content

Commit b590fef

Browse files
committed
feat(version): add const constructor
1 parent f401e32 commit b590fef

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,17 @@ pub struct Version {
266266
}
267267

268268
impl Version {
269+
/// Create [Version] with a major, minor, and patch version.
270+
pub const fn new(major: u64, minor: u64, patch: u64) -> Self {
271+
Self {
272+
major,
273+
minor,
274+
patch,
275+
build: Vec::new(),
276+
pre_release: Vec::new(),
277+
}
278+
}
279+
269280
/// True if this [Version] satisfies the given [Range].
270281
pub fn satisfies(&self, range: &Range) -> bool {
271282
range.satisfies(self)

0 commit comments

Comments
 (0)