Skip to main content

Module non_empty

Module non_empty 

Source
Expand description

Non-emptiness invariant for Content<'src>.

AST variants like Ruby and Bouten semantically require non-empty content payloads (an empty ruby base is a parse bug, not a valid state).

NonEmpty<Content<'src>> makes the invariant a build-time fact: the NonEmpty::new constructor returns Option, so empty content cannot enter the AST without a deliberate unwrap / expect. The allocator (aozora_syntax::alloc) does the expect exactly once per node variant — Phase 3’s classifier guarantees the input is non-empty, and an empty payload at allocation time signals a pipeline-internal bug rather than valid input.

Read access is via Deref so existing consumers of Content inherent methods (as_plain, iter) work unchanged on NonEmpty<Content>.

Structs§

NonEmpty
Non-emptiness wrapper for an AST payload.
NonEmptyStr
Non-empty &'src str newtype.