2022-01-04 12:21:08 +03:00
|
|
|
// Copyright (c) 2019-2022 Alexander Medvednikov. All rights reserved.
|
2021-03-12 12:28:04 +03:00
|
|
|
// Use of this source code is governed by an MIT license
|
|
|
|
// that can be found in the LICENSE file.
|
|
|
|
module mathutil
|
|
|
|
|
2022-01-05 19:02:20 +03:00
|
|
|
[deprecated: 'use math.min instead']
|
|
|
|
[deprecated_after: '2022-01-19']
|
2021-03-12 12:28:04 +03:00
|
|
|
[inline]
|
|
|
|
pub fn min<T>(a T, b T) T {
|
2021-05-03 14:14:32 +03:00
|
|
|
return if a < b { a } else { b }
|
2021-03-12 12:28:04 +03:00
|
|
|
}
|
|
|
|
|
2022-01-05 19:02:20 +03:00
|
|
|
[deprecated: 'use math.max instead']
|
|
|
|
[deprecated_after: '2022-01-19']
|
2021-03-12 12:28:04 +03:00
|
|
|
[inline]
|
|
|
|
pub fn max<T>(a T, b T) T {
|
2021-05-03 14:14:32 +03:00
|
|
|
return if a > b { a } else { b }
|
2021-03-12 12:28:04 +03:00
|
|
|
}
|
|
|
|
|
2022-01-05 19:02:20 +03:00
|
|
|
[deprecated: 'use math.abs instead']
|
|
|
|
[deprecated_after: '2022-01-19']
|
2021-03-12 12:28:04 +03:00
|
|
|
[inline]
|
|
|
|
pub fn abs<T>(a T) T {
|
2021-05-03 14:14:32 +03:00
|
|
|
return if a > 0 { a } else { -a }
|
2021-03-12 12:28:04 +03:00
|
|
|
}
|