2022-01-04 10:21:08 +01:00
|
|
|
// Copyright (c) 2019-2022 Alexander Medvednikov. All rights reserved.
|
2021-03-12 10:28:04 +01: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 17:02:20 +01:00
|
|
|
[deprecated: 'use math.min instead']
|
|
|
|
[deprecated_after: '2022-01-19']
|
2021-03-12 10:28:04 +01:00
|
|
|
[inline]
|
|
|
|
pub fn min<T>(a T, b T) T {
|
2021-05-03 13:14:32 +02:00
|
|
|
return if a < b { a } else { b }
|
2021-03-12 10:28:04 +01:00
|
|
|
}
|
|
|
|
|
2022-01-05 17:02:20 +01:00
|
|
|
[deprecated: 'use math.max instead']
|
|
|
|
[deprecated_after: '2022-01-19']
|
2021-03-12 10:28:04 +01:00
|
|
|
[inline]
|
|
|
|
pub fn max<T>(a T, b T) T {
|
2021-05-03 13:14:32 +02:00
|
|
|
return if a > b { a } else { b }
|
2021-03-12 10:28:04 +01:00
|
|
|
}
|
|
|
|
|
2022-01-05 17:02:20 +01:00
|
|
|
[deprecated: 'use math.abs instead']
|
|
|
|
[deprecated_after: '2022-01-19']
|
2021-03-12 10:28:04 +01:00
|
|
|
[inline]
|
|
|
|
pub fn abs<T>(a T) T {
|
2021-05-03 13:14:32 +02:00
|
|
|
return if a > 0 { a } else { -a }
|
2021-03-12 10:28:04 +01:00
|
|
|
}
|