Björn@swg-empire.de to Programmer Humor@programming.dev · 1 year agoPretty straight forwardswg-empire.deimagemessage-square47linkfedilinkarrow-up1731arrow-down112file-text
arrow-up1719arrow-down1imagePretty straight forwardswg-empire.deBjörn@swg-empire.de to Programmer Humor@programming.dev · 1 year agomessage-square47linkfedilinkfile-text
minus-squaretiredofsametab@fedia.iolinkfedilinkarrow-up19·1 year agoNow call that C program from some other program in another language.
minus-squareJasonDJ@lemmy.ziplinkfedilinkarrow-up27·1 year agowith open('program.c', 'w') as f: f.write( """I'm not actually going to copy down the program... But you get the idea of the joke. Right?""")
minus-squareTraister101@lemmy.todaylinkfedilinkarrow-up1·1 year agoAh 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·1 year agounsafe 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.
minus-squarexthexder@l.sw0.comlinkfedilinkarrow-up7·1 year agoMay I present to you: https://github.com/mame/quine-relay
Now call that C program from some other program in another language.
with open('program.c', 'w') as f: f.write( """I'm not actually going to copy down the program... But you get the idea of the joke. Right?""")Rust, to make it safe.
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.
May I present to you: https://github.com/mame/quine-relay
It’s… Beautiful.