align_text

Crates.ioalign_text
lib.rsalign_text
version1.0.0
sourcesrc
created_at2023-07-18 04:52:37.701346
updated_at2023-07-18 04:52:37.701346
descriptionAligns lines in a block of text within a number of columns.
homepage
repositoryhttps://github.com/KhalilOuali/align-rs
max_upload_size
id919096
size11,330
Khalil Ouali (KhalilOuali)

documentation

README

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",
Commit count: 18

cargo fmt