Structures for holding strings.
This module contains string::Subsystem, which manages StringIds. Since StringId is a
dumb POD, two wrapper are provided: Text and Name. While both can hold strings, Name
is optimized for strings with a numeric suffix. Texts implement Deref<Target=str>,
which is not the case for Name, because of the optimization.
Examples
The string Subsystem can be created from a parent Logger:
# use slog;
use string;
# let logger = root;
#
let string_subsystem = new;
You can create a StringId with the Subsystem:
# use slog;
# let logger = root;
# let string_subsystem = new;
use StringId;
let id1 = new;
let id2 = new;
let id3 = new;
assert_ne!;
assert_eq!;
Text or Name can be created from a literal string:
# use slog;
# let logger = root;
# let string_subsystem = new;
use Text;
let text = new;
assert_eq!;
A Text can be converted into &str:
# use slog;
# let logger = root;
# let string_subsystem = new;
# use Text;
let text = new;
let s: &str = text.as_str;
assert_eq!
If you have a slice of valid UTF-8 bytes, you can make a Text or a Name
out of it.
# use slog;
# let logger = root;
# let string_subsystem = new;
# use Text;
let sparkle_heart = &;
// We know these bytes are valid, so we'll use `unwrap()`.
let sparkle_heart = from_utf8.unwrap;
assert_eq!;
let bytes = sparkle_heart.as_bytes;
assert_eq!;