Repository navigation
Make Files::new const for static initialization - #420
RanaPriyansh wants to merge 1 commit into
Conversation
|
The current-head CI run for The published source is unchanged. The local package, feature, workspace, formatting, and Clippy results remain as described above. No hosted test result is available yet. Codex used. |
|
I think this is a good change. But I wonder under what scenario this is useful? Maybe if you want to reference some source text that is known at compile time? Additionally, is there a |
|
A concrete use is a shared file database that starts empty and receives source files at runtime: static FILES: std::sync::Mutex<codespan::Files<String>> =
std::sync::Mutex::new(codespan::Files::new());This permits static initialization without a lazy initializer. The source text does not need to be known at compile time. Clippy has Codex used. |
Files::new()cannot currently initialize static storage. Make it aconst fnthat initializes the existing empty file vector, preserving runtime construction andDefault.Addresses #347 for
Files::new.Validation:
E0015and passes after the fix.Codex used.