MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / write

Method write

cranelift/srcgen/src/lib.rs:235–249  ·  view source on GitHub ↗

Write `self.lines` to a file.

(
        &self,
        filename: impl AsRef<std::path::Path>,
        directory: &std::path::Path,
    )

Source from the content-addressed store, hash-verified

233
234 /// Write `self.lines` to a file.
235 pub fn write(
236 &self,
237 filename: impl AsRef<std::path::Path>,
238 directory: &std::path::Path,
239 ) -> Result<(), error::Error> {
240 let path = directory.join(&filename);
241 eprintln!("Writing generated file: {}", path.display());
242 let mut f = fs::File::create(path)?;
243
244 for l in self.lines.iter().map(|l| l.as_bytes()) {
245 f.write_all(l)?;
246 }
247
248 Ok(())
249 }
250}
251
252/// Compute the indentation of s, or None of an empty line.

Callers 2

generate_rust_assemblerFunction · 0.45
emitMethod · 0.45

Calls 7

OkFunction · 0.85
as_bytesMethod · 0.80
write_allMethod · 0.80
createFunction · 0.50
joinMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected