console-rs / indicatif

A command line progress reporting library for Rust
MIT License
4.21k stars 238 forks source link

Add `VisualLines` newtype wrapper #616

Closed smoelius closed 6 months ago

smoelius commented 6 months ago

An attempt to add a newtype wrapper, as discussed in https://github.com/console-rs/indicatif/issues/612#issuecomment-1853498395 and https://github.com/console-rs/indicatif/issues/612#issuecomment-1860809497.

Notes

  1. The wrapper is called VisualLines because that was the term introduced in #608, but I am not tied to that name.
  2. This PR adds a dependency: derive_more.
  3. I did not modify the TermLike trait. It has both "height" and "width" characteristics, and it seemed weird to modify just one.
chris-laplante commented 6 months ago

Thanks! First impressions are that I actually really like this. There are a lot fewer casts than I expected. (I also didn't know about SliceIndex - that's pretty cool.)

The real question will be whether or not it makes the code clearer and easier to read though. I'm going to take some time to digest it over the next few days.

Thanks again for the work!

smoelius commented 6 months ago

@djc I think I addressed all of your comments. Please let me know if there are any I missed.