diff options
| author | Christian Hopps <chopps@labn.net> | 2025-02-26 21:13:47 +0000 |
|---|---|---|
| committer | Christian Hopps <chopps@labn.net> | 2025-03-03 12:14:22 +0000 |
| commit | b4000e0ad7db49275cf3f592df3ceeb35021c296 (patch) | |
| tree | fd878567ad4e49aab9483c136ead4a77363ed8a2 /rustlibd/sandbox.rs | |
| parent | 38c8603ebe694e92ef223df3a2c0c4c7fef43c13 (diff) | |
rustlibd: rust daemon templatedev/rust-skel
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'rustlibd/sandbox.rs')
| -rw-r--r-- | rustlibd/sandbox.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/rustlibd/sandbox.rs b/rustlibd/sandbox.rs new file mode 100644 index 0000000000..ca8a3c5ae4 --- /dev/null +++ b/rustlibd/sandbox.rs @@ -0,0 +1,29 @@ +// -*- coding: utf-8 -*- +// +// February 26 2025, Christian Hopps <chopps@labn.net> +// +// Copyright (c) 2025, LabN Consulting, L.L.C. +// +#![allow(clippy::disallowed_names)] + +// ======= +// HashMap +// ======= + +fn test_hashmap() { + let v: Vec<&str> = "foobar=1baz&&bf%2Clag".split('&').collect(); + let v: Vec<&str> = v.into_iter().filter(|&x| !x.is_empty()).collect(); + println!("HASHMAP: split: {:?}", v); + + let qmap: HashMap<_, _> = v + .into_iter() + .map(|x| x.split_once('=').unwrap_or((x, ""))) + .map(|(x, y)| (_percent_decode(x), _percent_decode(y))) + .map(|(x, y)| (String::from(x), String::from(y))) + .collect(); + println!("HASHMAP: qmap: {:?}", qmap); +} + +fn main() { + test_hashmap(); +} |
