1 #[cfg(feature = "hyphenation")]
2 extern crate hyphenation
;
5 #[cfg(feature = "hyphenation")]
6 use hyphenation
::{Language, Load, Standard}
;
7 #[cfg(feature = "term_size")]
10 #[cfg(not(feature = "term_size"))]
12 println
!("Please enable the term_size feature to run this example.");
15 #[cfg(feature = "term_size")]
17 #[cfg(not(feature = "hyphenation"))]
18 fn new_wrapper
<'a
>() -> (&'
static str, Wrapper
<'a
, textwrap
::HyphenSplitter
>) {
19 ("without hyphenation", Wrapper
::with_termwidth())
22 #[cfg(feature = "hyphenation")]
23 fn new_wrapper
<'a
>() -> (&'
static str, Wrapper
<'a
, Standard
>) {
24 let dictionary
= Standard
::from_embedded(Language
::EnglishUS
).unwrap();
27 Wrapper
::with_splitter(textwrap
::termwidth(), dictionary
),
31 let example
= "Memory safety without garbage collection. \
32 Concurrency without data races. \
33 Zero-cost abstractions.";
34 // Create a new Wrapper -- automatically set the width to the
35 // current terminal width.
36 let (msg
, wrapper
) = new_wrapper();
37 println
!("Formatted {} in {} columns:", msg
, wrapper
.width
);
39 println
!("{}", wrapper
.fill(example
));