-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wrap could return an iterator #59
Comments
Fixed by #79. |
There doesn't seem to be an iterator based portion of the crate any more :( |
Hey @Lokathor, you're right. The iterator conflicted with the full-paragraph wrapping I implemented a while ago: instead of looking at the text word-by-word, the algorithm looks at the entire paragraph and finds globally optimal break points for it. My expectation is that most strings are fairly small, so do you have a use-case where it's too expensive to keep a full |
Naw it's a terminal program for desktop usage (a text game), so it's not too expensive in terms of space or speed. I just always look for the iterator version of stuff first and was sad to see that this iterator had disappeared at some point in the versioning. |
Yeah, I think it would be nice to support iteration, but it conflicts with Or rather: I guess an iterator could be added, with the understanding that you will be iterating over lines which are already formed in memory. The iterator could make sense for At a high level, I would be more interested in implementing #224, which is about wrapping while keeping state. So you could imagine feeding in text piece by piece and then getting the wrapped lines back in smaller chunks as well. |
The
wrap
method currently returnsVec<String>
but it could return an iterator instead. This would make it possible to output a large help text line-by-line and do less allocations.However, if
wrap
is mostly called throughfill
, this might not really improve anything sincefill
still needs to copy the data into a new string.The text was updated successfully, but these errors were encountered: