1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: only allow defining == and < and auto generate !=, >, >= and <= (#8520)

This commit is contained in:
Swastik Baranwal
2021-02-03 19:48:38 +05:30
committed by GitHub
parent 9dcf673216
commit 7ec116d588
14 changed files with 88 additions and 152 deletions

View File

@ -9,12 +9,6 @@ pub fn (t1 Time) == (t2 Time) bool {
return false
}
// operator `!=` returns true if provided time is not equal to time
[inline]
pub fn (t1 Time) != (t2 Time) bool {
return !(t1 == t2)
}
// operator `<` returns true if provided time is less than time
[inline]
pub fn (t1 Time) < (t2 Time) bool {
@ -24,27 +18,6 @@ pub fn (t1 Time) < (t2 Time) bool {
return false
}
// operator `<=` returns true if provided time is less or equal to time
[inline]
pub fn (t1 Time) <= (t2 Time) bool {
return t1 < t2 || t1 == t2
}
// operator `>` returns true if provided time is greater than time
[inline]
pub fn (t1 Time) > (t2 Time) bool {
if t1.unix > t2.unix || (t1.unix == t2.unix && t1.microsecond > t2.microsecond) {
return true
}
return false
}
// operator `>=` returns true if provided time is greater or equal to time
[inline]
pub fn (t1 Time) >= (t2 Time) bool {
return t1 > t2 || t1 == t2
}
// Time subtract using operator overloading.
[inline]
pub fn (lhs Time) - (rhs Time) Duration {