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

Method delimited_block

crates/codegen/src/code_indenter.rs:68–80  ·  view source on GitHub ↗

Print an indented block delimited by `before` and `after`, with body written by `f`.

(&mut self, before: &str, f: impl FnOnce(&mut Self) -> Res, after: &str)

Source from the content-addressed store, hash-verified

66
67 /// Print an indented block delimited by `before` and `after`, with body written by `f`.
68 pub fn delimited_block<Res>(&mut self, before: &str, f: impl FnOnce(&mut Self) -> Res, after: &str) -> Res {
69 self.writer.write_str(before).unwrap();
70 let res = self.with_indent(|out| {
71 out.newline();
72 // Need an explicit `write_indent` call here because calling `out.newline`
73 // will not cause the subsequent line to be indented, as `write_str` thinks
74 // it's an empty line.
75 out.write_indent().unwrap();
76 f(out)
77 });
78 self.writer.write_str(after).unwrap();
79 res
80 }
81}
82impl<W: fmt::Write> fmt::Write for CodeIndenter<W> {
83 fn write_str(&mut self, s: &str) -> fmt::Result {

Callers 8

generate_reducer_fileMethod · 0.80
define_enum_for_sumFunction · 0.80
print_reducer_enum_defnFunction · 0.80
print_db_update_defnFunction · 0.80
print_applied_diff_defnFunction · 0.80

Calls 5

with_indentMethod · 0.80
newlineMethod · 0.80
unwrapMethod · 0.45
write_strMethod · 0.45
write_indentMethod · 0.45

Tested by

no test coverage detected