parser/rust: improve word method comments and examples

Signed-off-by: cancaicai <2356672992@qq.com>
This commit is contained in:
cancaicai 2025-02-16 21:13:39 +08:00
parent 017fd006c6
commit 8c9de7c7ab
No known key found for this signature in database
GPG key ID: AAFE81DBD71A0DB3

View file

@ -2714,7 +2714,7 @@ where
}
}
/// Matches an entire `str` and moves the state's position forward if it succeeds.
/// Matches an entire `str` at the beginning of the state's bytes and moves the state's position forward if it succeeds.
///
/// # Example
///
@ -2741,6 +2741,10 @@ where
/// let (progress, problem) = parser.parse(&arena, State::new("bye, world".as_bytes()), 0).unwrap_err();
/// assert_eq!(progress, Progress::NoProgress);
/// assert_eq!(problem, Problem::NotFound(Position::zero()));
///
/// let (progress, problem) = parser.parse(&arena, State::new("world, hello".as_bytes()), 0).unwrap_err();
/// assert_eq!(progress, Progress::NoProgress);
/// assert_eq!(problem, Problem::NotFound(Position::zero()));
/// ```
pub fn word<'a, ToError, E>(word: &'static str, to_error: ToError) -> impl Parser<'a, (), E>
where