Minify impl of has_main_section()
This commit is contained in:
parent
95105986b1
commit
58a42d127d
2 changed files with 5 additions and 10 deletions
|
@ -1146,7 +1146,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_imag_section() {
|
||||
use super::has_main_section;
|
||||
use toml_ext::has_main_section;
|
||||
|
||||
let mut map = BTreeMap::new();
|
||||
map.insert("imag".into(), Value::Table(BTreeMap::new()));
|
||||
|
@ -1156,7 +1156,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_imag_invalid_section_type() {
|
||||
use super::has_main_section;
|
||||
use toml_ext::has_main_section;
|
||||
|
||||
let mut map = BTreeMap::new();
|
||||
map.insert("imag".into(), Value::Boolean(false));
|
||||
|
@ -1166,7 +1166,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_imag_abscent_main_section() {
|
||||
use super::has_main_section;
|
||||
use toml_ext::has_main_section;
|
||||
|
||||
let mut map = BTreeMap::new();
|
||||
map.insert("not_imag".into(), Value::Boolean(false));
|
||||
|
|
|
@ -429,13 +429,8 @@ fn has_only_tables(t: &Table) -> bool {
|
|||
t.iter().all(|(_, x)| is_match!(*x, Value::Table(_)))
|
||||
}
|
||||
|
||||
fn has_main_section(t: &Table) -> bool {
|
||||
t.contains_key("imag") &&
|
||||
match t.get("imag") {
|
||||
Some(&Value::Table(_)) => true,
|
||||
Some(_) => false,
|
||||
None => false,
|
||||
}
|
||||
pub fn has_main_section(t: &Table) -> bool {
|
||||
t.contains_key("imag") && is_match!(t.get("imag"), Some(&Value::Table(_)))
|
||||
}
|
||||
|
||||
fn has_imag_version_in_main_section(t: &Table) -> bool {
|
||||
|
|
Loading…
Reference in a new issue