Skip to main content

parse_recoverable

Function parse_recoverable 

Source
pub fn parse_recoverable<'de>(
    document: &'de str,
    arena: &'de Arena,
) -> Document<'de>
Available on crate feature from-toml only.
Expand description

Parses a TOML document in recovery mode, accumulating errors instead of stopping on the first one.

Always returns a Document (never Err). Syntax errors are collected into the document’s Context::errors alongside any later deserialization errors. Valid portions of the input are still parsed into the tree.

Recovery is line-based: when a statement fails, the parser skips to the next line and continues. At most 25 errors are collected before parsing stops.

§Examples

let arena = toml_spanner::Arena::new();
let mut doc = toml_spanner::parse_recoverable("key = 'value'\nbad =\n", &arena);
assert_eq!(doc["key"].as_str(), Some("value"));
assert!(!doc.errors().is_empty());