We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9c6f56b commit b3aef37Copy full SHA for b3aef37
src/project.rs
@@ -31,10 +31,12 @@ impl RustAnalyzerProject {
31
32
/// Write rust-project.json to disk
33
pub fn write_to_disk(&self) -> Result<(), std::io::Error> {
34
- std::fs::write(
35
- "./rust-project.json",
36
- serde_json::to_vec(&self).expect("Failed to serialize to JSON"),
37
- )?;
+ // Using the capacity 2^14 = 16384 since the file length in bytes is higher than 2^13.
+ // The final length is not known exactly because it depends on the user's sysroot path,
+ // the current number of exercises etc.
+ let mut buf = Vec::with_capacity(16384);
38
+ serde_json::to_writer(&mut buf, &self).expect("Failed to serialize to JSON");
39
+ std::fs::write("rust-project.json", buf)?;
40
Ok(())
41
}
42
0 commit comments