pub struct NestingTooDeep {
pub max_depth: usize,
pub offset: usize,
pub line: usize,
pub column: usize,
pub line_text: String,
}Expand description
A document that nests links deeper than the parser allows, with the position of the level that is one too deep.
Every parenthesized group and every indentation level is one level of nesting. The parser recurses once per level, so the limit is what turns a document that would overflow the stack, and abort the process, into an error.
§Examples
use links_notation::{parse_lino_with_config, ParseError, ParserConfig};
let config = ParserConfig::new().with_max_depth(1);
assert!(parse_lino_with_config("(a (b))", &config).is_err());
let Err(ParseError::NestingTooDeep(error)) = parse_lino_with_config("((a))", &config) else {
panic!("expected the nesting to be too deep")
};
assert_eq!((error.max_depth, error.line, error.column), (1, 1, 2));
assert_eq!(
error.to_string(),
"line 1, column 2: nesting depth exceeds the maximum of 1\n1 | ((a))\n | ^"
);Fields§
§max_depth: usizeThe deepest nesting the parser was configured to accept.
offset: usizeByte offset of the offending position from the start of the document.
line: usizeLine the offending position is on, counted from 1.
column: usizeColumn the offending position is at, in characters, counted from 1.
line_text: StringThe offending line, as written, without its line ending.
Implementations§
Trait Implementations§
Source§impl Clone for NestingTooDeep
impl Clone for NestingTooDeep
Source§impl Debug for NestingTooDeep
impl Debug for NestingTooDeep
Source§impl Display for NestingTooDeep
impl Display for NestingTooDeep
impl Eq for NestingTooDeep
Source§impl Error for NestingTooDeep
impl Error for NestingTooDeep
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl PartialEq for NestingTooDeep
impl PartialEq for NestingTooDeep
impl StructuralPartialEq for NestingTooDeep
Auto Trait Implementations§
impl Freeze for NestingTooDeep
impl RefUnwindSafe for NestingTooDeep
impl Send for NestingTooDeep
impl Sync for NestingTooDeep
impl Unpin for NestingTooDeep
impl UnsafeUnpin for NestingTooDeep
impl UnwindSafe for NestingTooDeep
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
Mutably borrows from an owned value. Read more