]>
git.proxmox.com Git - rustc.git/blob - vendor/gix-config/src/parse/section/unvalidated.rs
1 use bstr
::{BStr, ByteSlice}
;
3 /// An unvalidated parse result of a key for a section, parsing input like `remote.origin` or `core`.
4 #[derive(Debug, PartialEq, Ord, PartialOrd, Eq, Hash, Clone, Copy)]
6 /// The name of the section, like `remote` in `remote.origin`.
7 pub section_name
: &'a
str,
8 /// The name of the sub-section, like `origin` in `remote.origin`.
9 pub subsection_name
: Option
<&'a BStr
>,
13 /// Parse `input` like `remote.origin` or `core` as a `Key` to make its section specific fields available,
14 /// or `None` if there were not one or two tokens separated by `.`.
15 /// Note that `input` isn't validated, and is `str` as ascii is a subset of UTF-8 which is required for any valid keys.
16 pub fn parse(input
: impl Into
<&'a BStr
>) -> Option
<Self> {
17 let input
= input
.into();
18 let mut tokens
= input
.splitn(2, |b
| *b
== b'
.'
);
21 section_name
: tokens
.next()?
.to_str().ok()?
,
22 subsection_name
: tokens
.next().map(Into
::into
),