If ever there was an indication of a (private?) helper-crate use-case, this is probably it
I know from my own experience that things like a “helper-crate”, a “dependency” and an “import” can feel like very ‘heavy’ tools for such a seemingly trivial problem.
But “buffering” isn’t all that trivial! It’s quite hard to get all the edge-cases correct, as for example @Nemo157’s playground example shows, and you yourself have noticed the friction everywhere if you don’t do it correctly from the start.
I think this ‘heavy’ feeling is also exaggerated by the still mostly immature tooling… If just typing “bu” would autocomplete to “BufRead” AND automatically add the
use at the top, I think the friction would be a lot less.
If we had “refactor > extract into crate” like we have e.g. in Java, you would have made this helper crate already.
Also, if you come from C or Java backgrounds, where dependency management is still mostly non-existant (as in C), or took literal decades to become somewhat usable (Java/Maven), than the reservations about adding dependencies make total, complete, utter sense: They’re a LOT of hassle!
Here probably the
npm community has successfully outgrown its reservations, if trivial things like
left-pad have their own package.
This really shows that even “trivial” things can be very good candidates for a (helper) package, if the package manager is good enough that the cost of “adding dependencies” is low enough.
I’d definately say
cargo is up to the task there