pub fn insert_line_before(text: &str, idx: usize, line: &str) -> StringExpand description
Insert line before line index idx, preserving the file’s line endings
and its trailing-newline habit.
line may itself be several lines (a generated method body); each is
re-emitted in the target file’s style, so a multi-line insert into a CRLF
file doesn’t leave bare \n behind.
Prefer declare_module or insert_before_marker — they find their own
anchor and decline when the file isn’t what they expected. Reach for this
only when the caller has located the line itself.