Skip to content
Snippets Groups Projects
Commit 91b49a77 authored by Jason Volk's avatar Jason Volk
Browse files

add basic exchange util


Signed-off-by: default avatarJason Volk <jason@zemos.net>
parent 5a17fbcc
No related branches found
No related tags found
1 merge request!530de-global services
......@@ -26,8 +26,16 @@
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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment