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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)