fn push_section_internal(
        &mut self,
        // current_section_name: Option<SectionHeaderName<'event>>,
        // current_subsection_name: Option<Cow<'event, str>>,
        header: ParsedSectionHeader<'event>,
        section: SectionBody<'event>,
    ) -> MutableSection<'_, 'event> {
        let new_section_id = SectionId(self.section_id_counter);
        self.section_headers.insert(new_section_id, header.clone());
        self.sections.insert(new_section_id, section);
        let lookup = self.section_lookup_tree.entry(header.name).or_default();

        let mut found_node = false;
        if let Some(subsection_name) = header.subsection_name {
            for node in lookup.iter_mut() {
                if let LookupTreeNode::NonTerminal(subsection) = node {
                    found_node = true;
                    subsection
                        // Clones the cow, not the inner borrowed str.
                        .entry(subsection_name.clone())
                        .or_default()
                        .push(new_section_id);
                    break;
                }
            }
            if !found_node {
                let mut map = HashMap::new();
                map.insert(subsection_name, vec![new_section_id]);
                lookup.push(LookupTreeNode::NonTerminal(map));
            }
        } else {
            for node in lookup.iter_mut() {
                if let LookupTreeNode::Terminal(vec) = node {
                    found_node = true;
                    vec.push(new_section_id);
                    break;
                }
            }
            if !found_node {
                lookup.push(LookupTreeNode::Terminal(vec![new_section_id]))
            }
        }
        self.section_order.push_back(new_section_id);
        self.section_id_counter += 1;
        self.sections.get_mut(&new_section_id).map(MutableSection::new).unwrap()
    }
/// Adds a new section to the config file.
Adds a new section to the config file.
Adds a new section to the config file .
fn push_section_internal(
        &mut self,
        // current_section_name: Option<SectionHeaderName<'event>>,
        // current_subsection_name: Option<Cow<'event, str>>,
        header: ParsedSectionHeader<'event>,
        section: SectionBody<'event>,
    ) -> MutableSection<'_, 'event> {
        let new_section_id = SectionId(self.section_id_counter);
        self.section_headers.insert(new_section_id, header.clone());
        self.sections.insert(new_section_id, section);
        let lookup = self.section_lookup_tree.entry(header.name).or_default();
        let mut found_node = false;
        if let Some(subsection_name) = header.subsection_name {
            for node in lookup.iter_mut() {
                if let LookupTreeNode::NonTerminal(subsection) = node {
                    found_node = true;
                    subsection
                        // Clones the cow, not the inner borrowed str.
                        .entry(subsection_name.clone())
                        .or_default()
                        .push(new_section_id);
                    break;
                }
            }
            if !found_node {
                let mut map = HashMap::new();
                map.insert(subsection_name, vec![new_section_id]);
                lookup.push(LookupTreeNode::NonTerminal(map));
            }
        } else {
            for node in lookup.iter_mut() {
                if let LookupTreeNode::Terminal(vec) = node {
                    found_node = true;
                    vec.push(new_section_id);
                    break;
                }
            }
            if !found_node {
                lookup.push(LookupTreeNode::Terminal(vec![new_section_id]))
            }
        }
        self.section_order.push_back(new_section_id);
        self.section_id_counter += 1;
        self.sections.get_mut(&new_section_id).map(MutableSection::new).unwrap()
    }
fn push_section_internal ( & mut self , // current_section_name: Option<SectionHeaderName<'event>>, // current_subsection_name: Option<Cow<'event, str>>, header : ParsedSectionHeader < ' event > , section : SectionBody < ' event > , ) -> MutableSection < ' _ , ' event > { let new_section_id = SectionId ( self . section_id_counter ) ; self . section_headers . insert ( new_section_id , header . clone ( ) ) ; self . sections . insert ( new_section_id , section ) ; let lookup = self . section_lookup_tree . entry ( header . name ) . or_default ( ) ; let mut found_node = false ; if let Some ( subsection_name ) = header . subsection_name { for node in lookup . iter_mut ( ) { if let LookupTreeNode :: NonTerminal ( subsection ) = node { found_node = true ; subsection // Clones the cow, not the inner borrowed str. . entry ( subsection_name . clone ( ) ) . or_default ( ) . push ( new_section_id ) ; break ; } } if ! found_node { let mut map = HashMap :: new ( ) ; map . insert ( subsection_name , vec ! [ new_section_id ] ) ; lookup . push ( LookupTreeNode :: NonTerminal ( map ) ) ; } } else { for node in lookup . iter_mut ( ) { if let LookupTreeNode :: Terminal ( vec ) = node { found_node = true ; vec . push ( new_section_id ) ; break ; } } if ! found_node { lookup . push ( LookupTreeNode :: Terminal ( vec ! [ new_section_id ] ) ) } } self . section_order . push_back ( new_section_id ) ; self . section_id_counter += 1 ; self . sections . get_mut ( & new_section_id ) . map ( MutableSection :: new ) . unwrap ( ) }
Adds a new section to the config file.
Adds a new section to the config file .
&mut self
header
ParsedSectionHeader<'event>
section
SectionBody<'event>