Today I discovered how pointers really work in Rust! So I decided I'm gonna share my example with you guys.
Пікірлер: 9
@DudeBroVideos Жыл бұрын
Apologies on the quality of the recording, I was zoomed out a bit on the terminal and I will do better next time!
@karthikeyanvj2 ай бұрын
nice one!! thank you!
@DudeBroVideosАй бұрын
It looks like this video caught the algorithm! If anyone wants to hear a very without all the "umm"s and "uhh"s then make sure to check out my less scuffed version on my other channel! kzfaq.info/get/bejne/at2SdcqT1NnZlI0.html
@lukasloen4659Ай бұрын
using raw pointers for this is a pretty bad idea, given that they're allowed to be dangling, so if a user is ever dropped or moved in memory, that pointer won't point to them anymore, and dereferencing them would be a read after free error, and casting them to a reference creates undefined behavior as the compiler assumes that references are always valid. that's why dereferencing them requires unsafe, you have to uphold the rules, not the compiler.
@DudeBroVideosАй бұрын
Looks like my video got through on the algorithm, you are absolutely right about this! This is quite frankly a very crude way of going about this but also a rather straightforward one as well. There are other ways of achieving the same thing without the "unsafe" block but still leak memory nonetheless like the Rc method using mutable borrows.
@fredhglАй бұрын
What IDE and plugins r u using? Thanks in advance
@DudeBroVideosАй бұрын
I'm not using an ide but I have configured Neovim with vim-plug. Currently the important plugins I'm using are coc, bufferline, lualine, and neo-tree. Some of those have other plugins you have to add in order for them to work but that's the basic rundown.
@gustavojoaquin_arch28 күн бұрын
Why you didn't use the native built-in lsp @@DudeBroVideos
@hanyanglee9018Ай бұрын
Basically, a ref is a ptr with a lifetime. This solution doesn't look useful in real cases. Maybe we need another video?