pub fn collect<'a>(
module: &'a Module<'a>,
src: &str,
span: &SpanIndex<'_>,
anchors: &[(usize, usize)],
) -> (Vec<FnUnit<'a>>, usize)Expand description
Collect every def, async def, method, nested def, and lambda from module.
src must be the same BOM-stripped buffer that was passed to parse_module
(so that name.value subslice pointer arithmetic stays valid).
span must be the SpanIndex built from the same src buffer. The caller
builds it once and passes it here so only a single SpanIndex is
constructed per file ā this function no longer builds its own.
anchors must be the pre-computed lambda_anchors(src) result (unwrapped by the
caller). Accepting anchors here (rather than calling lambda_anchors internally)
ensures tokenization happens exactly once per file ā the caller obtains the
anchors, handles the None failure case, threads the slice in, and the count
invariant below closes the silent-drop hole without a second tokenizer pass.
Returns (units, lambda_node_count) where lambda_node_count is the number of
Lambda AST nodes encountered during the walk ā incremented once per node,
regardless of whether an anchor was available and a unit was emitted. The caller
must compare this against anchors.len() to detect Nā M bijection breaks in
release builds (the in-body debug_assert_eq! catches drift in debug/test only).