semver: use operator overloading (#19935)

This commit is contained in:
Swastik Baranwal 2023-11-19 20:20:12 +05:30 committed by GitHub
parent 4b347a8881
commit 7e280a4b61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 28 deletions

View file

@ -70,26 +70,41 @@ pub fn (ver Version) satisfies(input string) bool {
}
// eq returns `true` if `v1` is equal to `v2`.
@[deprecated: 'use v1 == v2 instead']
pub fn (v1 Version) eq(v2 Version) bool {
return compare_eq(v1, v2)
}
// == checks if `v1` is equal to `v2`
pub fn (v1 Version) == (v2 Version) bool {
return compare_eq(v1, v2)
}
// gt returns `true` if `v1` is greater than `v2`.
@[deprecated: 'use v1 > v2 instead']
pub fn (v1 Version) gt(v2 Version) bool {
return compare_gt(v1, v2)
}
// < checks if `v1` is less than `v2`.
pub fn (v1 Version) < (v2 Version) bool {
return compare_lt(v1, v2)
}
// lt returns `true` if `v1` is less than `v2`.
@[deprecated: 'use v1 < v2 instead']
pub fn (v1 Version) lt(v2 Version) bool {
return compare_lt(v1, v2)
}
// ge returns `true` if `v1` is greater than or equal to `v2`.
@[deprecated: 'use v1 >= v2 instead']
pub fn (v1 Version) ge(v2 Version) bool {
return compare_ge(v1, v2)
}
// le returns `true` if `v1` is less than or equal to `v2`.
// le returns `true` if `v1` is less than or equal to `v2`
@[deprecated: 'use v1 <= v2 instead']
pub fn (v1 Version) le(v2 Version) bool {
return compare_le(v1, v2)
}