-
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
Make indent preserve existing newlines in the input string #279
Conversation
Before, indent("foo", "") would give "foo\n". It now preserves any trailing newline character present in the input string. This makes indent behave consistently with dedent. New tests ere added to ensure this on a number of corner cases. closes mgeisler#207
I guess this causes bound checking, but I think I prefer that.
Hey @jRimbault, thanks for removing the unsafe code again! Until someone shows up with a performance problem (with benchmarks...), there's no need for unsafe code here 😄 |
I'll get on to it soon :) |
Hi @jRimbault, no stress! That's the beauty of open source 😄 |
... and thanks! |
I tried making some fuzz work but I don't understand quite what it's testing for ? Panics ? The examples here don't seem to actually test things ? In any case I think your solution to simply add an enumerating index is really quite good since it doesn't need bumping the MSRV ( |
Yes, you raise a good point and you guessed correctly: they simply test that the code doesn't panic 😄 I should really document this...
Fair enough, I like it a lot that you ported those tests. They give us a nice foundation and we can then always think about turning them into property-based tests later. You're definitely right that it's much cheaper to have some solid unit tests for this. |
Happy to help 😄 |
Textwrap behavior changed after mgeisler/textwrap#279
Textwrap behavior changed after mgeisler/textwrap#279 Closes: #7705
Textwrap behavior changed after mgeisler/textwrap#279 Closes: diem#7705
I ported a custom iterator to get the inclusive split feature specifically with a
char
(though it could be even be just a custom iterator with\n
as a const value).This fixes #207 on stable rust but I'd feel safer once we're able to use the much more generic
split_inclusive
, hopefully.It usesIt's up to you @mgeisler if you want to make an exception or not.unsafe
code. Which is forbidden in this crate.