Skip to main content

declare_module

Function declare_module 

Source
pub fn declare_module(text: &str, decl: &str) -> Option<String>
Expand description

Add a module declaration (mod foo; / pub mod foo;) to a file’s module list, placed before the first existing declaration so the list stays readable at the top of the file.

Returns None when the declaration is already there (idempotent — the second generator run is a no-op) or when the file declares no modules at all and there’s no obvious place to put one. The caller reports it as a manual step rather than guessing.