Crates.io | str-ctx |
lib.rs | str-ctx |
version | 0.0.1 |
source | src |
created_at | 2024-06-13 21:39:23.482442 |
updated_at | 2024-06-13 21:39:23.482442 |
description | Simple string context map |
homepage | |
repository | https://github.com/holochain/str-ctx |
max_upload_size | |
id | 1271416 |
size | 16,586 |
Simple string context map.
let ctx = StrCtx::from_iter([("hello", "zombies")]);
assert_eq!("[hello:zombies]", &format!("{ctx}"));
let ctx = ctx.derive([("friend", "apple")]);
assert_eq!("[friend:apple,hello:zombies]", &format!("{ctx}"));
let ctx = ctx.derive([("hello", "world")]);
assert_eq!("[friend:apple,hello:world]", &format!("{ctx}"));
let ctx: Vec<(&'static str, String)> = ctx.into_iter().collect();
assert_eq!(
&[("friend", "apple".into()), ("hello", "world".into())],
ctx.as_slice(),
);