add clamp util.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
4becbed2a7
commit
4a57592378
1 changed files with 3 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
pub(crate) mod error;
|
||||
|
||||
use std::{
|
||||
cmp,
|
||||
cmp::Ordering,
|
||||
fmt,
|
||||
str::FromStr,
|
||||
|
@ -14,6 +15,8 @@ use ruma::{canonical_json::try_from_json_map, CanonicalJsonError, CanonicalJsonO
|
|||
|
||||
use crate::{services, Error, Result};
|
||||
|
||||
pub(crate) fn clamp<T: Ord>(val: T, min: T, max: T) -> T { cmp::min(cmp::max(val, min), max) }
|
||||
|
||||
pub(crate) fn millis_since_unix_epoch() -> u64 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
|
|
Loading…
Add table
Reference in a new issue