pub struct Sanitizer;
Implementations§
Source§impl Sanitizer
impl Sanitizer
Sourcepub fn parse(string: &str) -> ParserResult<'_, &str>
pub fn parse(string: &str) -> ParserResult<'_, &str>
Removes all leading whitespaces and comments from the given input, returning the sanitized input.
Sourcepub fn parse_whitespaces(string: &str) -> ParserResult<'_, &str>
pub fn parse_whitespaces(string: &str) -> ParserResult<'_, &str>
Removes leading whitespaces from the given input.
Sourcepub fn parse_comments(string: &str) -> ParserResult<'_, &str>
pub fn parse_comments(string: &str) -> ParserResult<'_, &str>
Removes multiple leading comments from the given input.
Sourcepub fn parse_comment(string: &str) -> ParserResult<'_, &str>
pub fn parse_comment(string: &str) -> ParserResult<'_, &str>
Removes the first leading comment from the given input.
Sourcepub fn parse_safe_char(string: &str) -> ParserResult<'_, char>
pub fn parse_safe_char(string: &str) -> ParserResult<'_, char>
Parse a safe character (in the sense explained in [string_parser::is_char_supported]). Returns an error if no character is found or a non-safe character is found. The character is returned, along with the remaining input.
This is used for otherwise unconstrained characters in (line and block) comments and in string literals.
Note also that the nom
documentation for anychar
says that
it matches one byte as a character.
However, simple experiments show that it matches a Unicode character,
e.g. attempting to parse "\u{4141}"
yields one CJK character and exhausts the input,
as opposed to returning A
and leaving another A
in the input.
Auto Trait Implementations§
impl Freeze for Sanitizer
impl RefUnwindSafe for Sanitizer
impl Send for Sanitizer
impl Sync for Sanitizer
impl Unpin for Sanitizer
impl UnwindSafe for Sanitizer
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more