pub fn remove_section<'lookup>(
        &mut self,
        section_name: &'lookup str,
        subsection_name: impl Into<Option<&'lookup str>>,
    ) -> Option<SectionBody> {
        let id = self
            .get_section_ids_by_name_and_subname(section_name, subsection_name.into())
            .ok()?
            .pop()?;
        self.section_order.remove(
            self.section_order
                .iter()
                .position(|v| *v == id)
                .expect("Section order does not contain section that we were trying to remove"),
        );
        self.sections.remove(&id)
    }
/// Removes the section, returning the events it had, if any. If multiple
/// sections have the same name, then the last one is returned. Note that
/// later sections with the same name have precedent over earlier ones.
///
/// # Examples
///
/// Creating and removing a section:
///
/// ```
/// # use git_config::file::{GitConfig, GitConfigError};
/// # use std::convert::TryFrom;
/// let mut git_config = GitConfig::try_from(
/// r#"[hello "world"]
///     some-value = 4
/// "#).unwrap();
///
/// let events = git_config.remove_section("hello", Some("world".into()));
/// assert_eq!(git_config.to_string(), "");
/// ```
///
/// Precedence example for removing sections with the same name:
///
/// ```
/// # use git_config::file::{GitConfig, GitConfigError};
/// # use std::convert::TryFrom;
/// let mut git_config = GitConfig::try_from(
/// r#"[hello "world"]
///     some-value = 4
/// [hello "world"]
///     some-value = 5
/// "#).unwrap();
///
/// let events = git_config.remove_section("hello", Some("world".into()));
/// assert_eq!(git_config.to_string(), "[hello \"world\"]\n    some-value = 4\n");
/// ```
Removes the section, returning the events it had, if any. If multiple
sections have the same name, then the last one is returned. Note that
later sections with the same name have precedent over earlier ones.
Removes the section returning the events it had if any . If multiple sections have the same name then the last one is returned . Note that later sections with the same name have precedent over earlier ones .
pub fn remove_section<'lookup>(
        &mut self,
        section_name: &'lookup str,
        subsection_name: impl Into<Option<&'lookup str>>,
    ) -> Option<SectionBody> {
        let id = self
            .get_section_ids_by_name_and_subname(section_name, subsection_name.into())
            .ok()?
            .pop()?;
        self.section_order.remove(
            self.section_order
                .iter()
                .position(|v| *v == id)
                .expect("Section order does not contain section that we were trying to remove"),
        );
        self.sections.remove(&id)
    }
pub fn remove_section < ' lookup > ( & mut self , section_name : & ' lookup str , subsection_name : impl Into < Option < & ' lookup str > > , ) -> Option < SectionBody > { let id = self . get_section_ids_by_name_and_subname ( section_name , subsection_name . into ( ) ) . ok ( ) ? . pop ( ) ? ; self . section_order . remove ( self . section_order . iter ( ) . position ( | v | * v == id ) . expect ( " " ) , ) ; self . sections . remove ( & id ) }
Removes the section, returning the events it had, if any.
Removes the section returning the events it had if any .
&mut self
section_name
&'lookup str
subsection_name
impl Into<Option<&'lookup str>>
examples
Creating and removing a section.


Creating and removing a section .
use git_config::file::{gitconfig, gitconfigerror};
None
use std::convert::tryfrom;
let mut git_config = GitConfig::try_from(
r#"[hello "world"]
some-value = 4
"#).unwrap().

let events = git_config.remove_section("hello", Some("world".into()));
assert_eq!(git_config.to_string(), "");
```

Precedence example for removing sections with the same name.


let mut git_config = GitConfig :: try_from ( r# " [ hello " world " ] some - value = 4 " # ) . unwrap () . let events = git_config . remove_section ( " hello " Some ( " world " . into () )) ; assert_eq! ( git_config . to_string () " " ) ; ` ` ` Precedence example for removing sections with the same name .
use git_config::file::{gitconfig, gitconfigerror};
None
use std::convert::tryfrom;
let mut git_config = GitConfig::try_from(
r#"[hello "world"]
some-value = 4
[hello "world"]
some-value = 5
"#).unwrap().

let events = git_config.remove_section("hello", Some("world".into()));
assert_eq!(git_config.to_string(), "[hello \"world\"]\n    some-value = 4\n");
```
let mut git_config = GitConfig :: try_from ( r# " [ hello " world " ] some - value = 4 [ hello " world " ] some - value = 5 " # ) . unwrap () . let events = git_config . remove_section ( " hello " Some ( " world " . into () )) ; assert_eq! ( git_config . to_string () " [ hello \ " world \ " ] \ n some - value = 4 \ n " ) ; ` ` `