Rust as_ref and as_mut Usage in the Linked List
Recently, I tried to write leetcode by rust. Everything goes well until I started to write code for linked list. The borrow check is quite verbose and I got stuck by the borrow check when handling Option<Box<LinkedNode>>
more than the problem itself.
It's sad to find I don't understand the borrow check well, but it's also a good chance to find these missing knowledge for me.
This blog discusses about as_ref
, as_mut
and take
of the Option
.