]> git.lizzy.rs Git - rust.git/blobdiff - src/shape.rs
Make children list in-order
[rust.git] / src / shape.rs
index 6cf0e8ea8908b62534fd45ea38e2e7e5a29c6be8..12a911a19315a583d9a62e733758567725cf7ad9 100644 (file)
@@ -27,6 +27,7 @@ pub struct Indent {
 const INDENT_BUFFER_LEN: usize = 80;
 const INDENT_BUFFER: &str =
     "\n                                                                                ";
+
 impl Indent {
     pub fn new(block_indent: usize, alignment: usize) -> Indent {
         Indent {
@@ -273,6 +274,12 @@ pub fn comment(&self, config: &Config) -> Shape {
         );
         Shape { width, ..*self }
     }
+
+    pub fn to_string_with_newline(&self, config: &Config) -> Cow<'static, str> {
+        let mut offset_indent = self.indent;
+        offset_indent.alignment = self.offset;
+        offset_indent.to_string_inner(config, 0)
+    }
 }
 
 #[cfg(test)]