Shape is one of the key abstractions in Rustfmt, representing the space into which an AST node can be written. Unfortunately it is a mess - the structure is weird, the fields are badly named, and the methods are unintuitive. Documentation is also non-existent. We can do better!
we should not have so many different kinds of indent - backing out of an indent shouldn't be the shapes responsibility. We might want to have something like a stack of shapes or something to make that easier
we should store an rhs offset and compute the width, rather than storing the width
we might want to get rid of Indent and just have Shape, although Indent does abstract over tabs/spaces nicely
ideally we should not force clients to manually adjust the shape, but when we should have a unifed mechanism to write into a buffer and compute the 'next' shape
Shape
is one of the key abstractions in Rustfmt, representing the space into which an AST node can be written. Unfortunately it is a mess - the structure is weird, the fields are badly named, and the methods are unintuitive. Documentation is also non-existent. We can do better!