You are right. But after removing the element, nothing points to it, so it's dropped. It would be easier if the elements implement the clone trait. I had to do a general case scenario without using any unsafe block
@@cudidotdev why not return the RC. Would that work? I'm not at my PC right now. Liked list is an interesting problem in Rust for sure! I think you did a decent job at tackling it. :)
@@cudidotdevI think the best way is to do the if let Some on &self.head.take(). This way, you will get ownership of the RC. Then you can call &self.head.replace() with the value obtained by calling next.
Hey good video, you're doing a great job
Thank you. This means a lot to me
Very nice content
Thanks for the nice comments 💙
Shouldn't pop return the element it pops off the list?
You are right. But after removing the element, nothing points to it, so it's dropped. It would be easier if the elements implement the clone trait. I had to do a general case scenario without using any unsafe block
@@cudidotdev why not return the RC. Would that work? I'm not at my PC right now.
Liked list is an interesting problem in Rust for sure! I think you did a decent job at tackling it. :)
I think so. You can try and let me know
@@cudidotdevI think the best way is to do the if let Some on &self.head.take(). This way, you will get ownership of the RC. Then you can call &self.head.replace() with the value obtained by calling next.
@@LtdJorge I will try that and see