mgeisler/textwrap

Make term_size an optional dependency

H2CO3 opened this issue · 3 comments

H2CO3 commented

Currently, term_size is a required dependency of this crate. This means that all consumers of this library must also install the transitive closure of term_size's dependencies, even those who are not willing to use its functionality.

This is an especially important consideration given that term_size makes heavy use of unsafe, so crates with a zero-unsafe policy (such as one I am currently authoring) may not be able to use textwrap even though they don't actually need any of its unsafe-dependent functionality.

Since with_termwidth() is more or less trivial, and the termwidth() function literally just wraps term_size with a hardcoded default value, it seems to me that it is not the right trade-off that has been made in this regard.

Consequently, I suggest one of the following, in decreasing order of preference:

  • Remove the term_size dependency, termwidth(), and with_termwidth() altogether, because the latter two are trivial and the default value of 80 might not be suitable for everyone anyway.
  • Make with_termwidth() and termwidth() a non-default, optional feature and term_size an optional dependency, so they are not included by default, but those who are willing to use the functionality can still continue doing so without breaking code changes.
  • Make with_termwidth() and termwidth() a default, optional feature and term_size an optional dependency, so they are included by default, but those who are not willing to use the functionality can opt out.

This is blocking clap-rs/clap#1055.

@H2CO3 Thanks for the idea — you're right that it's just a matter of a trivial wrapper and that we can leave it out by default.

H2CO3 commented

@mgeisler Great, I'm glad you found this useful. 🙂