Settings

Theme

I still don’t understand the * operator in Rust

micouy.github.io

2 points by micouay 4 years ago · 1 comment

Reader

ankurdhama 4 years ago

You have to understand the difference between a move and a copy. "let b = a" can have 2 meaning - either copy a value to b if a supports copy or move the value a to b and now you cannot use a anymore. Similarly if you did "let a = *b" (where b is a reference) you are doing either a move or a copy depending on b's type. If b doesnt support copy then this will fail to compile as you are trying to move from a reference which is not possible as moving requires ownership of the value and the reference only borrowed it.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection