pub trait Atom {
// Required method
fn parse(&self, st: &str) -> Option<Match>;
// Provided methods
fn as_dyn(&self) -> &dyn Atom
where Self: Sized { ... }
fn into_tool(self) -> AtomTool<Self>
where Self: Sized { ... }
}Expand description
The main parsing trait
Every object which incapsulate a parsing strategy should implement this trait in order to be composed with other atoms.
Required Methods§
Provided Methods§
Implementations on Foreign Types§
Source§impl Atom for char
Matches the first character exactly.
impl Atom for char
Matches the first character exactly.
use minparser::prelude::MatchHelper;
let view = Into::<MatchHelper>::into("My data");
view.match_atom('M').unwrap().match_atom('y').unwrap();Source§impl Atom for fn(MatchHelper<'_>) -> Result<MatchHelper<'_>, MatchHelper<'_>>
impl Atom for fn(MatchHelper<'_>) -> Result<MatchHelper<'_>, MatchHelper<'_>>
Source§impl Atom for fn(MatchHelper<'_>) -> MatchHelper<'_>
impl Atom for fn(MatchHelper<'_>) -> MatchHelper<'_>
Source§impl Atom for str
Matches a string exactly
impl Atom for str
Matches a string exactly
use minparser::prelude::*;
let view = Into::<MatchHelper>::into("My data ");
view.match_atom("My dat").unwrap().match_atom("a ").unwrap();Source§impl<R> Atom for [R]where
R: Atom,
Matches any of the atoms in the slice.
impl<R> Atom for [R]where
R: Atom,
Matches any of the atoms in the slice.
use minparser::prelude::MatchHelper;
let view = Into::<MatchHelper>::into("My data");
view.match_atom(&['M', 'K', 'O']).unwrap().match_atom(&["ser", "ii", "y d"]).unwrap();Source§impl<R, const N: usize> Atom for [R; N]where
R: Atom,
Matches any of the atoms in the array.
impl<R, const N: usize> Atom for [R; N]where
R: Atom,
Matches any of the atoms in the array.
use minparser::atoms::MatchHelper;
let view = Into::<MatchHelper>::into("My data");
view.match_atom(['M', 'K', 'O']).unwrap().match_atom(["ser", "ii", "y d"]).unwrap();