1
Fork 0

move single component parsing to dedicated function

this will prevent parsing when expecting more than a single component
to be parsed, and prepare for the symetric variant-to-name function to
be added
This commit is contained in:
Rémy Rakic 2023-09-20 20:09:06 +00:00
parent acc3b61c5e
commit 2ce46f8e8c
3 changed files with 12 additions and 13 deletions

View file

@ -539,18 +539,17 @@ bitflags::bitflags! {
}
}
impl FromStr for LinkSelfContainedComponents {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
impl LinkSelfContainedComponents {
/// Parses a single `-Clink-self-contained` well-known component, not a set of flags.
pub fn from_str(s: &str) -> Option<LinkSelfContainedComponents> {
Some(match s {
"crto" => LinkSelfContainedComponents::CRT_OBJECTS,
"libc" => LinkSelfContainedComponents::LIBC,
"unwind" => LinkSelfContainedComponents::UNWIND,
"linker" => LinkSelfContainedComponents::LINKER,
"sanitizers" => LinkSelfContainedComponents::SANITIZERS,
"mingw" => LinkSelfContainedComponents::MINGW,
_ => return Err(()),
_ => return None,
})
}
}