View source code
Display the source code in std/string.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
std.string.outdent
- multiple declarations
- Function outdent
- Function outdent
Function outdent
Removes one level of indentation from an array of single-line strings.
This uniformly outdents the text as much as possible.
Whitespace-only lines
are always converted to blank lines
.
Prototype
S[] outdent(S)( S[] lines ) pure @safe if (isSomeString!S);
Parameters
Name | Description |
---|---|
lines | array of single-line strings |
Returns
Throws
StringException
if indentation is done with different sequences
of whitespace characters.
Function outdent
Removes one level of indentation from a multi-line string.
This uniformly outdents the text as much as possible. Whitespace-only lines are always converted to blank lines.
Does not allocate memory if it does not throw.
Prototype
S outdent(S)( S str ) pure @safe if (isSomeString!S);
Parameters
Name | Description |
---|---|
str | multi-line string |
Returns
outdented string
Throws
StringException
if indentation is done with different sequences
of whitespace characters.
Example
enum pretty = q{ import std.stdio; void main() { writeln("Hello"); } }.outdent(); enum ugly = q{ import std.stdio; void main() { writeln("Hello"); } }; assert(pretty == ugly);
Authors
Walter Bright, Andrei Alexandrescu, and Jonathan M Davis