reset

Function reset 

Source
pub fn reset<C: Cost>(d: Doc<C>) -> Doc<C>
Expand description

Resets the indentation level for a document to 0.

This can be useful for things like multiline strings, where the indentation is temporarily reset.

After rendering d, the indentation level will return to its previous value.

ยงExample

let doc = text("def gen1_starters():") &
          nest(4, nl() &
                  text("print ") &
                  reset(text("'''") & nl() &
                        text("Bulbasaur") & nl() &
                        text("Charmander") & nl() &
                        text("Squirtle") & nl() &
                        text("'''")) &
                  nl() &
                  text("return True"));

assert_eq!(doc.to_string(),
r"def gen1_starters():
    print '''
Bulbasaur
Charmander
Squirtle
'''
    return True");