I would like to take a bool
from a Vec<bool>
and compare it in an if statement. How do I solve the following error?
|
7 | if cell {
| ^^^^ expected bool, found &bool
|
= note: expected type `bool`
found type `&bool`
if cell.clone()
works for me but seems a bit hackisch.
Just do that:
bool
implementsCopy
, so indexing the array will copy the value out.If you had a reference to the boolean inside the vector, you will need to dereference it:
Or