Closed
Description
This works:
fn mul<T:Num>(x: &T, y: &T) -> T { *x * *y }
But this doesn't:
fn mul<T:Num>(&x: &T, &y: &T) -> T { x * y }
<anon>:7:23: 7:25 error: cannot move out of dereference of & pointer
<anon>:7 fn mul<T:Num>(&x: &T, &y: &T) -> T { x * y }
^~
<anon>:7:31: 7:33 error: cannot move out of dereference of & pointer
<anon>:7 fn mul<T:Num>(&x: &T, &y: &T) -> T { x * y }
^~
The above &t: &T
pattern could cut down on tons of repetitive derefs within function bodies.
Metadata
Metadata
Assignees
Labels
No labels