From a2699db7cf2769d76ea2d4331f7bdd02f5fe1f57 Mon Sep 17 00:00:00 2001 From: JamieH01 Date: Wed, 31 Jan 2024 19:15:46 -0500 Subject: [PATCH] Parsable trait --- src/traits.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/traits.rs b/src/traits.rs index a7fe99a6f..7325012be 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -1079,6 +1079,14 @@ impl<'a, R: FromStr> ParseTo for &'a str { } } +/// Provides a parser for a given type +pub trait Parsable: Sized { + /// The associated error which can be returned from parsing. + type Err; + /// Attempt to parse this type, returning an [`IResult`] + fn parse(s: O) -> IResult; +} + impl InputLength for [u8; N] { #[inline] fn input_len(&self) -> usize {