2017-02-24

Hi all,

I've been working on a simple crate for text wrapping and when I saw that there is a cool hyphenation crate on crates.io, I added support for it. Your command line programs can now have automatically hyphenated and word-wrapped help output

Unfortunately, the hyphenation crate pulls in a number of dependencies and takes about a minute to compile. So making this dependency optional seems like a reasonable thing to do in case people don't care for the hyphenation.

My question is now if I should make hyphenation a default feature of the textwrap crate, or if I should make it opt-in? Is there a rule of thumb in the Rust world about this?

I guess the question is how easy it is for users to opt-in and opt-out, an in particular how easy it is to change this if my textwrap crate is an indirect dependency? I found this topic about this — there the conclusion seems to be that there's no easy way for users to opt-in to an optional feature while being sure that they use the same version as the library in question.

Also, as I understand it, it's a little easier to opt-in as a user: you simply specify the features you want in addition to the default features of a crate:

Opting out is harder since you cannot just subtract a feature from the list of default features:

(In my case, simply enabling hyphenation on it's own won't do anything since the user would also need to select the hyphenation patterns to use. So if textwrap is an indirect dependency, you can only use hyphenation if your direct dependency has a way of letting you specify a hyphenation pattern.)

Thanks for any insights!

Show more