pub(super) fn table<'a>(parent: &'a toml::Table, key: &str) -> Option<&'a toml::Table> {
parent.get(key).and_then(toml::Value::as_table)
}
pub(super) fn string<'a>(parent: &'a toml::Table, key: &str) -> Option<&'a str> {
parent.get(key).and_then(toml::Value::as_str)
}
pub(super) fn flag(parent: &toml::Table, key: &str, default: bool) -> bool {
parent
.get(key)
.and_then(toml::Value::as_bool)
.unwrap_or(default)
}
pub(super) fn strings(parent: &toml::Table, key: &str) -> Box<[Box<str>]> {
parent
.get(key)
.and_then(toml::Value::as_array)
.map(|values| {
values
.iter()
.filter_map(toml::Value::as_str)
.map(Box::<str>::from)
.collect()
})
.unwrap_or_default()
}
pub(super) fn tables<'a>(parent: &'a toml::Table, key: &str) -> Box<[&'a toml::Table]> {
parent
.get(key)
.and_then(toml::Value::as_array)
.map(|values| values.iter().filter_map(toml::Value::as_table).collect())
.unwrap_or_default()
}
pub(super) fn inherits(parent: &toml::Table, key: &str) -> bool {
table(parent, key).is_some_and(|entry| flag(entry, "workspace", false))
}
pub(super) fn aliased_table<'a>(parent: &'a toml::Table, keys: &[&str]) -> Option<&'a toml::Table> {
keys.iter().find_map(|key| table(parent, key))
}