MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / write_str

Method write_str

crates/codegen/src/code_indenter.rs:83–94  ·  view source on GitHub ↗
(&mut self, s: &str)

Source from the content-addressed store, hash-verified

81}
82impl<W: fmt::Write> fmt::Write for CodeIndenter<W> {
83 fn write_str(&mut self, s: &str) -> fmt::Result {
84 for (i, line) in s.split_inclusive('\n').enumerate() {
85 let write_indent = i != 0 || std::mem::take(&mut self.needs_indenting);
86 // skip the indent if it's an empty line
87 if write_indent && line != "\n" {
88 self.write_indent()?;
89 }
90 self.writer.write_str(line)?;
91 }
92 self.needs_indenting = s.ends_with('\n');
93 Ok(())
94 }
95}
96impl CodeIndenter<String> {
97 // This method allows `write!` and `writeln!` to be used directly on `CodeIndenter`.

Callers 15

fmtMethod · 0.45
fmtMethod · 0.45
expectingMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
print_stmt_resultFunction · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
fmtMethod · 0.45
cpp_ty_fmt_implFunction · 0.45

Calls 3

takeFunction · 0.85
OkFunction · 0.50
write_indentMethod · 0.45

Tested by

no test coverage detected