allow LenientError to be serializable too

This commit is contained in:
Kat Lim Ruiz
2025-03-30 11:26:20 -05:00
parent 3e660905a7
commit 1a9fd885dd
2 changed files with 4 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
//! nom combinators for infallible operations
use std::convert::Infallible;
use serde::Serialize;
use nom::{AsChar, IResult, InputLength, InputTakeAtPosition};
pub(crate) type ErrorList = Vec<LenientErrorInternal>;
@@ -15,7 +15,7 @@ pub(crate) struct LenientErrorInternal {
}
/// A recoverable error and the position it happened at
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Serialize)]
pub struct LenientError {
pub pos: usize,
pub message: String,

View File

@@ -47,5 +47,7 @@ mod tests {
fn test_parse_query_lenient_wrong_query() {
let (_, errors) = parse_query_lenient("title:");
assert!(errors.len() == 1);
let json = serde_json::to_string(&errors).unwrap();
assert_eq!(json, r#"[{"pos":6,"message":"expected word"}]"#);
}
}