12345678910111213141516171819202122 |
- use gecliht;
- fn main () {
- let languages = ["Rust", "Ruby", "Java"];
- println!("Working with languages {}.", gecliht::words_with_commas(&languages));
- // display large piece of text
- let text = "Miss Bennet’s astonishment was soon lessened by the strong sisterly partiality which made any admiration of Elizabeth appear perfectly natural; and all surprise was shortly lost in other feelings. She was sorry that Mr. Darcy should have delivered his sentiments in a manner so little suited to recommend them; but still more was she grieved for the unhappiness which her sister’s refusal must have given him.";
- display_text(&text, 80);
- display_text(&text, 40);
- }
- fn display_text(text: &str, width: usize) {
- println!("\n{:->width$}", "-", width=width);
- for line in gecliht::word_wrap(&text, width).iter() {
- println!("{}", line);
- }
- }
|