Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Funny, this
undef_method
delegates#==
and#!
to@obj
and makes this the shortest solution!||=
withbegin … end
seems like a concise way to do more complex lazy initialization!And I never considered ending a
.each
with&& nil
if it's the last expression in a method.Yes.
&mut res
creates a mutable reference, and passing it toreduce
makes a mutable borrow.It is still checked by Rust's borrow checker with even more stringent rules to avoid having multiple mutable references to a value or a shared reference (
&
) and a mutable reference to the same value.Meanwhile, I'm reading in the book (19.1. Unsafe Rust » Dereferencing a Raw Pointer) that in unsafe Rust it's possible to create and dereference "raw pointers" where the above restrictions don't apply.