I can't control every -sys crate out there
-
-
Manish Retweeted Manish
Manish added,
1 reply 0 retweets 1 like -
-
Replying to @ManishEarth @yaahc_ and
Right, I get that. But there's a ton of code out there that doesn't or won't know to do this.
1 reply 0 retweets 2 likes -
right, i don't dispute that :) i agree that CString cannot be deprecated, it is useful in far too many ways and for cases like the one you say before, my original point in this thread was that CString cannot be deprecated
1 reply 0 retweets 2 likes -
Replying to @ManishEarth @yaahc_ and
Right. What I'd love to see is a change that removes the footgun for everyone (which does imply deprecating as_ptr), but doing that in a way which interops with existing code taking *const char and resists misuse is important
1 reply 0 retweets 3 likes -
Replying to @sgrif @ManishEarth and
Any solution which requires you to know about the footgun and actively do something to avoid it isn't any better than the current situation
1 reply 0 retweets 4 likes -
That's true. I think replacing as_ptr with an &*const c_char method could be good but it does have some similar issues
1 reply 0 retweets 1 like -
Replying to @ManishEarth @yaahc_ and
Yeah that seems really easy to try doing a pointer cast instead of a dereference. Making &c_char created from a *c_char not UB seems most tractable to me
1 reply 0 retweets 2 likes -
Replying to @sgrif @ManishEarth and
The biggest upside of that RFC is that if CStr guarantees its memory repr we can have bindgen always generate &CStr for arguments, but: This means we lose the ability to do takes_cstr(returns_cstr()) That doesn't help with all the existing code out there taking *const char
1 reply 0 retweets 2 likes
Also not everyone uses bindgen and I don't necessarily expect everyone writing a c binding to know "&CStr has the same memory repr as *const c_char and I should always use that"
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.