icerpc / slicec

The Slice compiler library
Apache License 2.0
13 stars 5 forks source link

Simplify `CodeBlock` API #693

Closed InsertCreativityHere closed 7 months ago

InsertCreativityHere commented 7 months ago

Removed 2 trait implementations were unused by slicec-cs. One was for converting iterators of strings into CodeBlocks, this is very niche, so the one place we used it was probably deleted. The other was for converting CodeBlocks to Strings. This was just redundant. We always call to_string on CodeBlocks, or pass them into format! macros (which internally calls to_string), so we never directly convert CodeBlocks to Strings.


It also changes indent and add_block to take owned parameters, instead of &muts. Because right now we're doing lots of: add_block(&builder.build()) and add_block(&format!(...)) This change will let us remove that & in the middle. There's no real reason for it tbh, except that our API here demands it.