You'd still need the signature to take that type though instead of a raw pointer
-
-
yeah, this doesn't obviate the need for CString, but it obviates the need for CString in footgun-prone APIs you control
2 replies 0 retweets 2 likes -
Replying to @ManishEarth @yaahc_ and
For APIs you control is the key part here. I can already wrap things with a really small wrapper that takes &CStr. Removing the footgun for APIs you don't control is the important bit. If we're relying on all developers doing the thing that is more work we will be sad
1 reply 0 retweets 1 like -
well, no, you can control the rust bindings but maybe not the C header.
1 reply 0 retweets 1 like -
Replying to @ManishEarth @yaahc_ and
I can't control every -sys crate out there
1 reply 0 retweets 1 like -
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
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
-
-
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 - 2 more replies
New conversation -
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.