-
Notifications
You must be signed in to change notification settings - Fork 3
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
Implement Base.one for StringView #24
Conversation
I have a lot of `S where S<:AbstractString` code which uses `one(S)` for the empty string to compare against. I didn't realize until I went to add this that `typemin` also works, but hey, that makes the implementation that much easier, and StringViews gives me a zero-copy drop-in replacement for a string buffer with this addition.
Looks good to me, can you add a test? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #24 +/- ##
==========================================
+ Coverage 75.05% 77.08% +2.02%
==========================================
Files 6 6
Lines 417 467 +50
==========================================
+ Hits 313 360 +47
- Misses 104 107 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
And a test for identity equality
Done. I admittedly have been making these edits through the GitHub interface, after trying them in the REPL. It looks like tests run under CI? I'm willing to clone and run locally if necessary. |
Co-authored-by: Steven G. Johnson <[email protected]>
Co-authored-by: Steven G. Johnson <[email protected]>
Also defined for Strings
Good catch, a careful look at the documentation also turned up |
As well as a custom typemin for StringView(Base.CodeUnits{etc}}. This makes the Base implementation of typemin function for both s and su in the test suite, and I would consider returning the data field for an attempt to convert a StringView to its underlying data to be legitimate.
This commit got rid of the custom It adds a |
Just chiming in to say that I intend to squash all of this into one commit whenever you think it's in a good state to merge. I ended up checking in some spurious data among other things. Speaking of which, would you accept a separate PR which adds I'm not in a rush here, to be clear. I ended up switching two calls to use |
I don't like including a |
Right, I removed it once I realized it came from me. The |
Would you say this is ready to go? I'd like to squash it, so the spurious check-ins don't end up in the tree. I've held off because that should really be done once. |
Thanks, I squashed and merged. |
I have a lot of
S where S<:AbstractString
code which usesone(S)
for the empty string to compare against. I didn't realize until I went to add this thattypemin
also works, but hey, that makes the implementation that much easier, and StringViews gives me a zero-copy drop-in replacement for a string buffer with this addition.