mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-26 07:34:25 +00:00
add basic exchange util
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
5a17fbccf5
commit
91b49a7786
|
@ -26,8 +26,16 @@ pub use string::{str_from_bytes, string_from_bytes};
|
|||
pub use sys::available_parallelism;
|
||||
pub use time::now_millis as millis_since_unix_epoch;
|
||||
|
||||
#[inline]
|
||||
pub fn clamp<T: Ord>(val: T, min: T, max: T) -> T { cmp::min(cmp::max(val, min), max) }
|
||||
|
||||
#[inline]
|
||||
pub fn exchange<T: Clone>(state: &mut T, source: T) -> T {
|
||||
let ret = state.clone();
|
||||
*state = source;
|
||||
ret
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn generate_keypair() -> Vec<u8> {
|
||||
let mut value = rand::string(8).as_bytes().to_vec();
|
||||
|
|
Loading…
Reference in a new issue