forked from gentoo-utils/gentoo-utils
impl atom parsing
This commit is contained in:
10
src/useflag/mod.rs
Normal file
10
src/useflag/mod.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
pub mod parsers;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct UseFlag(String);
|
||||
|
||||
impl UseFlag {
|
||||
pub fn get(&self) -> &str {
|
||||
self.0.as_str()
|
||||
}
|
||||
}
|
||||
10
src/useflag/parsers.rs
Normal file
10
src/useflag/parsers.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
use mon::{Parser, alpha1, alphanumeric, one_of, take_while};
|
||||
|
||||
use crate::useflag::UseFlag;
|
||||
|
||||
pub fn useflag<'a>() -> impl Parser<&'a str, Output = UseFlag> {
|
||||
alpha1()
|
||||
.and(alphanumeric().or(take_while(one_of("+_@-".chars()))))
|
||||
.recognize()
|
||||
.map(|output: &str| UseFlag(output.to_string()))
|
||||
}
|
||||
Reference in New Issue
Block a user