pub struct AlignOptions {
pub align: Alignment,
pub split: String,
pub pad: char,
}Expand description
Configuration options for text alignment operations.
This struct allows you to customize how text alignment is performed, including the alignment direction, line separator, and padding character.
§Examples
use ansi_align::{AlignOptions, Alignment, ansi_align_with_options};
// Basic usage with default settings
let opts = AlignOptions::new(Alignment::Center);
// Customized options
let opts = AlignOptions::new(Alignment::Right)
.with_split("|")
.with_pad('.');
let text = "short|longer text";
let result = ansi_align_with_options(text, &opts);Fields§
§align: AlignmentThe alignment type (left, center, right)
split: StringThe string to split lines on (default: “\n”)
pad: charThe padding character to use (default: “ “)
Implementations§
Source§impl AlignOptions
impl AlignOptions
Sourcepub fn with_split<S: Into<String>>(self, split: S) -> Self
pub fn with_split<S: Into<String>>(self, split: S) -> Self
Sets the string used to split lines using the builder pattern.
By default, lines are split on "\n", but you can specify any string
as a line separator.
§Arguments
split- The string to use as a line separator
§Examples
use ansi_align::{AlignOptions, Alignment};
let opts = AlignOptions::new(Alignment::Center)
.with_split("|")
.with_split("<->"); // Multi-character separators work tooSourcepub const fn with_pad(self, pad: char) -> Self
pub const fn with_pad(self, pad: char) -> Self
Sets the character used for padding using the builder pattern.
By default, spaces (' ') are used for padding, but you can specify
any character.
§Arguments
pad- The character to use for padding
§Examples
use ansi_align::{AlignOptions, Alignment};
let opts = AlignOptions::new(Alignment::Right)
.with_pad('.');Trait Implementations§
Source§impl Clone for AlignOptions
impl Clone for AlignOptions
Source§fn clone(&self) -> AlignOptions
fn clone(&self) -> AlignOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AlignOptions
impl Debug for AlignOptions
Auto Trait Implementations§
impl Freeze for AlignOptions
impl RefUnwindSafe for AlignOptions
impl Send for AlignOptions
impl Sync for AlignOptions
impl Unpin for AlignOptions
impl UnwindSafe for AlignOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more