macro_rules! value {
() => { ... };
($x:expr) => { ... };
([]) => { ... };
([$elem:expr; $n:expr]) => { ... };
([$($x:expr),+ $(,)?]) => { ... };
([=>]) => { ... };
([$k:expr => $v:expr; $n:expr]) => { ... };
([$($k:expr => $v:expr),+ $(,)?]) => { ... };
}Expand description
A macro that makes creating rmpv values easier
Create an nil value by just calling value with no arguments:
value!()Create any single Value by just calling value! with the expression that you want to convert.
This uses Value::from the hood
value!(true)
value!(3)Create an array of Values using syntax similar to vec!:
value!([]) // empty array
value!([3, 4, 2, 234, 213]);
value!([true, false, true true]);
value!([true; 10]); // repeat a valueCreate a map of Values using syntax similar to ruby
value!([=>]) // empty map
value!(["Cat" => false, "Dog" => true, "Fish" => false]);
value!(["Dog" => true; 9]); // repeat a key value pairNote: Value::Map is just a Vec<(Value, Value)>, not a HashMap