Skip to content

Usages of the Options struct #350

Answered by mgeisler
NeverGivinUp asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @NeverGivinUp, yes, that sounds pretty accurate.

My goal was to make the "top-level" functions easy to use for simple things, while also making it possible to customize things further when needed. So you can do

let wrapped = textwrap::wrap(some_text, 80);

or you can do

let wrapped = textwrap::wrap(some_text, Options::new(80).break_words(false).initial_indent("  "));

The Options struct is the centralized place which holds the configuration options. When using the core functions, you could just as well create a splitter and word_separator yourself -- in the WASM demo, I just used Options::new(width) since it gives me the default splitter and word_separator in an easy way.

If your point …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by NeverGivinUp
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #348 on May 06, 2021 16:53.