It doesn't have a different memory repr, but it does have narrowed provenance for the pointer you get. That's why the as_ptr method for slices first makes *const [T] and then makes *const T, in that very specific ordering. Sounds stupid, but RalfJ assures me it's true.
-
-
Wow that basically eliminates the ability to have a safer version of `as_ptr` for many types then. That's really unfortunate.
1 reply 0 retweets 0 likes -
Does it? Why can't it be a transparent type that is basically just the pointer, but has a PhantomData reference to the original CStr?
1 reply 0 retweets 0 likes -
Because a transparent type that is basically just the pointer can't be passed to a function that takes a pointer
1 reply 0 retweets 0 likes -
Well yeah, my argument is still to have that type in the function signature as well, so you never touch a raw pointer at all
1 reply 0 retweets 0 likes -
Sure, but now you have to change both `CString` *and* whatever it's being passed to, which you may or may not have control of. So I can't just release a "better CString" crate, I also have to release a "better libc" or whatever else to go along with it.
1 reply 0 retweets 2 likes -
There's a ton of code out there that works with raw pointers, expecting all of those signatures to change is a pipe dream IMO
1 reply 0 retweets 2 likes -
Libc, maybe not, smaller APIs might work. like you can make a better curses api fairly easily or whatever.
1 reply 0 retweets 0 likes -
Replying to @Lokathor
Miss Dada 🏳️⚧️ Retweeted Miss Dada 🏳️⚧️
Miss Dada 🏳️⚧️ added,
1 reply 0 retweets 0 likes -
Replying to @sgrif
Sorta? That presumes that people don't usually get their ffi bindings from bindings crate providers, which they usually do. Ditto for the safe wrapper crates. So it only takes a small portion of the population to get together and fix the situation for most others.
1 reply 0 retweets 0 likes
You're assuming all existing code will update and all new code will do the right thing
-
-
Replying to @sgrif
Just tell people you've got something better and convert them one user at a time.
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
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.