Skip to main content

Module register

Module register 

Source
Expand description

Conservative text-level edits to wire generated code into the existing builder chains.

Why not syn? Re-emitting Rust through syn + prettyplease loses formatting, comments, and blank-line layout — adopters then see a surprise diff every time they generate something. So this module takes a narrower approach: find a known anchor substring, insert one line, leave everything else alone.

The patterns we match are the exact ones the new scaffold emits plus what the users-api example demonstrates. Anything more creative (extracted-helper bootstrap, custom builder wrapper) is out of scope — the callers fall back to printing the manual hint.

Enums§

RegisterOutcome
Result of one auto-register attempt. The wrapping caller turns these into print lines.

Functions§

insert_chain_call_after_anchor
Insert new_call (a builder method like .module(modules::posts::define())) into contents at the right indentation, anchored to the last line containing anchor_substring.
insert_use_after_last_use
Insert a use ...; line just after the last existing use ...; line at the top of the file. Returns true if inserted, false if no use lines were found.