pub fn left(text: &str) -> StringExpand description
Align text to the left (no-op, returns original text)
Examples found in repository?
examples/basic_usage.rs (line 13)
3fn main() {
4 println!("=== Basic Alignment Examples ===\n");
5
6 // Simple text alignment
7 let text = "Hello\nWorld\nRust";
8
9 println!("Original text:");
10 println!("{}\n", text);
11
12 println!("Left aligned:");
13 println!("{}\n", left(text));
14
15 println!("Center aligned:");
16 println!("{}\n", center(text));
17
18 println!("Right aligned:");
19 println!("{}\n", right(text));
20
21 println!("=== ANSI Color Examples ===\n");
22
23 // Text with ANSI colors
24 let colored_text = "\x1b[31mRed\x1b[0m\n\x1b[32mGreen Text\x1b[0m\n\x1b[34mBlue\x1b[0m";
25
26 println!("Colored text (center aligned):");
27 println!("{}\n", center(colored_text));
28
29 println!("=== Unicode Examples ===\n");
30
31 // Unicode text with wide characters
32 let unicode_text = "古\n古古古\nHello 世界";
33
34 println!("Unicode text (right aligned):");
35 println!("{}\n", right(unicode_text));
36
37 println!("=== Custom Options Examples ===\n");
38
39 // Custom separator and padding
40 let pipe_separated = "Name|Age|Location";
41 let options = AlignOptions::new(Alignment::Center)
42 .with_split("|")
43 .with_pad('.');
44
45 println!("Custom separator and padding:");
46 println!("{}\n", ansi_align_with_options(pipe_separated, &options));
47
48 // Menu-like alignment
49 let menu = "🏠 Home\n📋 About Us\n📞 Contact\n⚙️ Settings";
50
51 println!("Menu (center aligned):");
52 println!("{}\n", center(menu));
53}