-
Notifications
You must be signed in to change notification settings - Fork 4
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
Refactor constructor safety #76
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
|
I think the sanitizer test is failing due to a bug in the sanitizer itself (given the obscure error referencing its source code). My guess is rust-lang/rust#111073 |
I'm at the fair with my family but noticed this come through and just wanted to say that I'm stoked about this one. I considered suggesting exposing Pointer::new but was hesitant. I'll review both tomorrow morning. Also, you're awesome dude. |
No rush, just came with a few ideas recently. I noticed |
Hah, you did! Perhaps not to hatch directly but the state of this crate would be in much worse shape without your contributions. You brought it up a few levels! :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you went above and beyond with comments in this one :)
Looks great to me!
Co-authored-by: Chance <[email protected]>
To be honest the unsafe for internal uses might be a bit overkill, I'm not 100% sure this is a great idea long term, but since it's an internal detail I think it's ok to experiment with. |
Although a lot more inconvenient for us, some of our functions have invariants that have to be held externally, so they should be
unsafe fn
. This also makes it justifiable to expose them publicly (as then users can opt-in for manual checking of the invariants).Notable changes:
Pointer::new
as a public (but unsafe) constructor (now calledPointer::new_unchecked
). This gives users a way to bypass validation if they're sure they've got a valid string. Akin toString::from_utf8_unchecked
and family.PointerBuf::new_unchecked
as a new unsafe constructor, to matchPointer::new_unchecked
.Token::from_encoded_unchecked
unsafe. This one I didn't make public because I don't see much use for it. We may revisit this later.