#[non_exhaustive]pub enum InlineComments {
None,
AfterWhitespace,
Anywhere,
}Expand description
Where comments start after values.
Lines that start with ; or # (after whitespace) are always comments.
use std::collections::BTreeMap;
use deser_ini::{DeserializerConfig, InlineComments};
let input = "a = 1;2 ; one\nb = x #y\nc = #fff";
let with = |comments| -> BTreeMap<String, String> {
DeserializerConfig::builder()
.inline_comments(comments)
.build()
.from_str(input)
.unwrap()
};
let values = with(InlineComments::AfterWhitespace);
assert_eq!((&*values["a"], &*values["b"], &*values["c"]), ("1;2", "x", "#fff"));
let values = with(InlineComments::None);
assert_eq!((&*values["a"], &*values["b"], &*values["c"]), ("1;2 ; one", "x #y", "#fff"));
let values = with(InlineComments::Anywhere);
assert_eq!((&*values["a"], &*values["b"], &*values["c"]), ("1", "x", ""));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
None
There are no comments after values (like Python’s configparser).
AfterWhitespace
A ; that follows whitespace starts a comment and so does a # that
follows whitespace after the value.
Values can contain ; and # that do not follow whitespace (1;2)
and start with # (#ff0000).
Anywhere
; and # start comments anywhere (outside of quoted values).
Trait Implementations§
Source§impl Clone for InlineComments
impl Clone for InlineComments
impl Copy for InlineComments
Source§impl Debug for InlineComments
impl Debug for InlineComments
Source§impl Default for InlineComments
impl Default for InlineComments
impl Eq for InlineComments
Source§impl PartialEq for InlineComments
impl PartialEq for InlineComments
impl StructuralPartialEq for InlineComments
Auto Trait Implementations§
impl Freeze for InlineComments
impl RefUnwindSafe for InlineComments
impl Send for InlineComments
impl Sync for InlineComments
impl Unpin for InlineComments
impl UnsafeUnpin for InlineComments
impl UnwindSafe for InlineComments
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