pub fn sniff_version(src: &str) -> Option<RustyfiVersion>Expand description
Best-effort detection of a document’s target version from its source text, by inspecting the header-like lines at the top of the file (before any prelude bindings), and, failing that, the first content line.
- A
@stage:header line is a real, direct signal: 0.1’s lexer rejects it outright, so seeing it at all yieldsSome(V0_0). @require:/@import:header lines are transparent: byte-identical in both v0.0.6 and dev-0-1-0, so their presence pins neither axis — they are skipped just like a blank/comment line.- A
use-shaped header line — 0.1/Saphe’s module-header syntax, seeis_use_header— yieldsSome(V0_1). This half of the heuristic is best-effort: the exact grammar could not be confirmed against upstream from this sandbox (no network access to GitHub / zenn.dev at the time this was written). - Blank lines and
%-comments (SATySFi’s line-comment syntax, both versions) are skipped while looking for the first header-shaped line. - Once a non-blank, non-comment, non-header line is reached (headers are
only valid at the top of a file), that single line is inspected for a
content-level signal (see
sniff_content_line) and the result — includingNone— is returned regardless. - Returns
Noneif no signal is found at all (e.g. a barelet ... in ...document with no headers, which is valid and version-ambiguous in 0.0.x).