pub struct KeyRef<'a> {
pub section_name: &'a str,
pub subsection_name: Option<&'a BStr>,
pub value_name: &'a str,
}
Expand description
An unvalidated parse result of parsing input like remote.origin.url
or core.bare
.
Fields§
§section_name: &'a str
The name of the section, like core
in core.bare
.
subsection_name: Option<&'a BStr>
The name of the subsection, like origin
in remote.origin.url
.
value_name: &'a str
The name of the section key, like url
in remote.origin.url
.
Implementations§
Source§impl KeyRef<'_>
impl KeyRef<'_>
Lifecycle
Sourcepub fn parse_unvalidated(input: &BStr) -> Option<KeyRef<'_>>
pub fn parse_unvalidated(input: &BStr) -> Option<KeyRef<'_>>
Parse input
like core.bare
or remote.origin.url
as a Key
to make its fields available,
or None
if there were not at least 2 tokens separated by .
.
Note that input
isn’t validated, and is str
as ascii is a subset of UTF-8 which is required for any valid keys.
Trait Implementations§
Source§impl AsKey for KeyRef<'_>
impl AsKey for KeyRef<'_>
Source§fn as_key(&self) -> KeyRef<'_>
fn as_key(&self) -> KeyRef<'_>
Return a parsed key reference, containing all relevant parts of a key.
For instance,
remote.origin.url
such key would yield access to ("remote", Some("origin"), "url")
while user.name
would yield ("user", None, "name")
. Read moreSource§fn try_as_key(&self) -> Option<KeyRef<'_>>
fn try_as_key(&self) -> Option<KeyRef<'_>>
Return a parsed key reference, containing all relevant parts of a key.
For instance,
remote.origin.url
such key would yield access to ("remote", Some("origin"), "url")
while user.name
would yield ("user", None, "name")
.Source§impl<'a> Ord for KeyRef<'a>
impl<'a> Ord for KeyRef<'a>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a> PartialOrd for KeyRef<'a>
impl<'a> PartialOrd for KeyRef<'a>
impl<'a> Copy for KeyRef<'a>
impl<'a> Eq for KeyRef<'a>
impl<'a> StructuralPartialEq for KeyRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for KeyRef<'a>
impl<'a> RefUnwindSafe for KeyRef<'a>
impl<'a> Send for KeyRef<'a>
impl<'a> Sync for KeyRef<'a>
impl<'a> Unpin for KeyRef<'a>
impl<'a> UnwindSafe for KeyRef<'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