align_text 1.0.0

Aligns lines in a block of text within a number of columns.
Documentation
  • Coverage
  • 15.38%
    2 out of 13 items documented1 out of 5 items with examples
  • Size
  • Source code size: 11.33 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 331.48 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • KhalilOuali/align-rs
    8 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • KhalilOuali

align_text: Align text within a specified width

This crate defines a trait Align with a method align_text() implemented for two types:

  • Vec<String> where each String is considered a line
  • String

You can specify the alignment, the number of columns, whether to wrap long lines, whether to trim lines first, etc.

Examples

  • align_text(Where::Center, Some((30, false)), true, Bias::Right, true)

Input lines:

"Hello           ",
"            World!",
"   This should center-align     ",

Output lines:

"             Hello            ",
"            World!            ",
"   This should center-align   ",
  • align_text(Where::Right, Some((40, false)), false, Bias::Left, false)

Input text's lines:

"graphic design"
"is my"
"pAsSiOn"
  • Output text's lines:
"             graphic design",
"             is my",
"             pAsSiOn",