pub enum Item<'a> {
Error(&'a str),
Section {
name: &'a str,
raw: &'a str,
},
SectionEnd,
Property {
key: &'a str,
val: Option<&'a str>,
raw: &'a str,
},
Comment {
raw: &'a str,
},
Blank {
raw: &'a str,
},
}
Expand description
A parsed element of syntatic meaning
Variants§
Error(&'a str)
Syntax error.
Section header element was malformed.
Malformed section headers are defined by a line starting with [
but
not ending with ]
.
assert_eq!(
ini_roundtrip::Parser::new("[Error").nth(1),
Some(ini_roundtrip::Item::Error("[Error")));
Section
Section header element.
assert_eq!(
ini_roundtrip::Parser::new("[Section]").nth(1),
Some(ini_roundtrip::Item::Section{name: "Section", raw: "[Section]"}));
SectionEnd
End of section.
Pseudo-element emitted before a Section
and at the
end of the document. This helps processing sections after their
properties finished parsing.
assert_eq!(
ini_roundtrip::Parser::new("").next(),
Some(ini_roundtrip::Item::SectionEnd));
Property
Property element.
Key value must not contain =
.
The value is None
if there is no =
.
assert_eq!(
ini_roundtrip::Parser::new("Key=Value").next(),
Some(ini_roundtrip::Item::Property{key: "Key", val: Some("Value"), raw: "Key=Value"}));
assert_eq!(
ini_roundtrip::Parser::new("Key").next(),
Some(ini_roundtrip::Item::Property{key: "Key", val: None, raw: "Key"}));
Comment
Comment.
assert_eq!(
ini_roundtrip::Parser::new(";comment").next(),
Some(ini_roundtrip::Item::Comment{raw: ";comment"}));
Blank
Blank line.
Allows faithful reproduction of the whole ini document including blank lines.
assert_eq!(
ini_roundtrip::Parser::new("\n").next(),
Some(ini_roundtrip::Item::Blank{raw: ""}));
Trait Implementations§
impl<'a> Copy for Item<'a>
impl<'a> Eq for Item<'a>
impl<'a> StructuralPartialEq for Item<'a>
Auto Trait Implementations§
impl<'a> Freeze for Item<'a>
impl<'a> RefUnwindSafe for Item<'a>
impl<'a> Send for Item<'a>
impl<'a> Sync for Item<'a>
impl<'a> Unpin for Item<'a>
impl<'a> UnwindSafe for Item<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more