mgeisler / textwrap

An efficient and powerful Rust library for word wrapping text.
MIT License
467 stars 45 forks source link

Change penalties to non-negative numbers #424

Closed mgeisler closed 2 years ago

mgeisler commented 2 years ago

The optimization problem solved by the optimal-fit algorithm is fundamentally an optimization problem where we seek to minimize a penalty cost. It is therefore not sensible to allow negative penalties since all penalties are there to discourage certain features:

Making this change surfaces the overflow bug behind #247 and #416. This will be fixed next via #421 and this commit can be seen as a way of simplifying that PR.