From 22a8f3d619e8ef89eeb9a60ab0a27aed01aa93f7 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sun, 27 Feb 2022 20:35:22 +0100 Subject: save all uploaded code bundles in database --- planetwars-server/src/util.rs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 planetwars-server/src/util.rs (limited to 'planetwars-server/src/util.rs') diff --git a/planetwars-server/src/util.rs b/planetwars-server/src/util.rs new file mode 100644 index 0000000..44fcf1c --- /dev/null +++ b/planetwars-server/src/util.rs @@ -0,0 +1,9 @@ +use rand::{distributions::Alphanumeric, Rng}; + +pub fn gen_alphanumeric(length: usize) -> String { + rand::thread_rng() + .sample_iter(&Alphanumeric) + .take(length) + .map(char::from) + .collect() +} -- cgit v1.2.3