BjörnA to Programmer Humor@programming.dev · vor 1 JahrPretty straight forwardimagemessage-square45linkfedilinkarrow-up1735arrow-down112file-text
arrow-up1723arrow-down1imagePretty straight forwardBjörnA to Programmer Humor@programming.dev · vor 1 Jahrmessage-square45linkfedilinkfile-text
minus-squareTraister101@lemmy.todaylinkfedilinkarrow-up1·vor 1 JahrAh yes now I can… dereference a raw pointer (yes that’s essentially the only thing unsafe rust actually enables you to do, it doesn’t disable the borrow checker or anything else, it just allows you to play with pointers)
minus-squarecalcopiritus@lemmy.worldlinkfedilinkarrow-up1·vor 1 Jahrunsafe fn<'a, T>(p: &'a T) -> &'static mut T { p as *cons T as *mut T as &'static mut T } It is a bit more than just dereferencing raw pointers.
step 1:
unsafe fn()…Ah yes now I can… dereference a raw pointer (yes that’s essentially the only thing unsafe rust actually enables you to do, it doesn’t disable the borrow checker or anything else, it just allows you to play with pointers)
unsafe fn<'a, T>(p: &'a T) -> &'static mut T { p as *cons T as *mut T as &'static mut T }It is a bit more than just dereferencing raw pointers.