Rust vector iteration less than 1 minute read The following example shows difference of iterating vector items between for and with iter() method 1 2 3 4 let vs = vec![1, 2, 3]; for (v : vs) { // consumes v, owned v } 1 2 3 4 let vs = vec![1, 2, 3]; for (v : &vs) { // borrows vs, & v } 1 2 3 4 let vs = vec![1, 2, 3]; for (v : vs.iter()) { // this is equivalent to for (v: &vs) } 1 2 3 4 let vs = vec![1, 2, 3]; for (v : vs.into_iter()) { // this is equivalent to for (v: vs) } Share on Twitter Facebook LinkedIn Previous Next
C++ - lvalue, rvalue abbreviations less than 1 minute read lvalue: locatable value(addressable value) xvalue: expiring value glvalue: generalizable lvalue, it will be lvalue or xvalue rvalue: not addressable value(no...
C++ - unique_ptr for custom resource less than 1 minute read Using unique_ptr for a custom resource such as opening a file.
C++ - template meta programming less than 1 minute read Please watch the following youtube to understand basic of C++ template meta programming
C++ - virtual destructor disable move semantic less than 1 minute read Declaring virtual destructor will disable move sematic