pub fn parse_cases_from_str<Setup, Expect>(
name: &str,
contents: &str,
) -> Result<Vec<EvalCase<Setup, Expect>>, EvalError>Expand description
Parse one .ron case file’s contents into a list of EvalCases, accepting EITHER authoring shape.
name is used only for error messages (typically the file path/stem). The parse tries the LIST form
(Vec<EvalCase>, RON [EvalCase(…), EvalCase(…)]) FIRST, and only if that fails falls back to the
SINGLE form (one EvalCase(…)), wrapping the lone case in a one-element Vec. List-first is the
correct order: a single EvalCase(…) can never parse as a Vec (it doesn’t start with [), so a
genuine single-case file flows cleanly to the fallback; whereas single-first would mis-handle a list.
§Error reporting when BOTH parses fail
A file that is neither a valid list nor a valid single case is a hard EvalError::RonParse naming
name. We report the single-case parse error as the source: for a file the author intended as one
case (the common shape, and what a typo’d single-case file is) it is the directly relevant message,
and for a genuinely-malformed list the single-parse error is just as diagnostic (RON still points at
the offending span). We do not silently drop the case.
Bounds: Setup: DeserializeOwned + Default (a case may omit setup); Expect: DeserializeOwned.