Manually implement Debug and make convert_error more generic.
This commit is contained in:
parent
288350daef
commit
14b1d0526c
@ -11,7 +11,7 @@ use nom::Slice;
|
|||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::error::MyError;
|
use crate::error::MyError;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct OrgSource<'s> {
|
pub struct OrgSource<'s> {
|
||||||
full_source: &'s str,
|
full_source: &'s str,
|
||||||
start: usize,
|
start: usize,
|
||||||
@ -24,6 +24,14 @@ pub struct OrgSource<'s> {
|
|||||||
parenthesis_depth: isize, // ()
|
parenthesis_depth: isize, // ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'s> std::fmt::Debug for OrgSource<'s> {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_tuple("OrgSource")
|
||||||
|
.field(&Into::<&str>::into(self))
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'s> OrgSource<'s> {
|
impl<'s> OrgSource<'s> {
|
||||||
/// Returns a wrapped string that keeps track of values we need for parsing org-mode.
|
/// Returns a wrapped string that keeps track of values we need for parsing org-mode.
|
||||||
///
|
///
|
||||||
@ -302,7 +310,9 @@ impl<'s> InputTakeAtPosition for OrgSource<'s> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn convert_error(err: nom::Err<CustomError<OrgSource<'_>>>) -> nom::Err<CustomError<&str>> {
|
pub fn convert_error<'a, I: Into<CustomError<&'a str>>>(
|
||||||
|
err: nom::Err<I>,
|
||||||
|
) -> nom::Err<CustomError<&'a str>> {
|
||||||
match err {
|
match err {
|
||||||
nom::Err::Incomplete(needed) => nom::Err::Incomplete(needed),
|
nom::Err::Incomplete(needed) => nom::Err::Incomplete(needed),
|
||||||
nom::Err::Error(err) => nom::Err::Error(err.into()),
|
nom::Err::Error(err) => nom::Err::Error(err.into()),
|
||||||
|
Loading…
Reference in New Issue
Block a user