String¶
A String value is a character vector — free-form text stored inline, byte for
byte. Unlike a symbol it is not interned, so strings suit unique
or high-cardinality text.
Atoms¶
let s = Value::string("a longer string value");
assert_eq!(s.as_string()?, "a longer string value");
// short and empty strings round-trip too
assert_eq!(Value::string("hi").as_string()?, "hi");
assert_eq!(Value::string("").as_string()?, "");
The empty string is the string null:
The Str wrapper¶
Because a bare &str converts to a symbol through ToValue, the
Str wrapper exists to ask for a string atom explicitly in the conversion
path.
So Value::string("x") and Str("x").to_value() produce the same string atom,
while "x".to_value() produces a symbol.
Vectors¶
Value::str_vec builds a vector of strings of any length.