From the tutorial on borrowed pointers (broken), slightly modified:
struct Point {x: float, y: float} fn compute(p1 : &Point) {} fn main() { let shared_box : @Point = @Point {x: 5.0, y: 1.0}; compute(shared_box); }
And that's all right, because the shared box is automatically borrowed for the function.
But do the same with the sign:
struct Point {x: float, y: float} trait TPoint {} impl TPoint for Point {} fn compute(p1 : &TPoint) {} fn main() { let shared_box : @TPoint = @Point {x: 5.0, y: 1.0} as @TPoint; compute(shared_box);
And it fails (compiler version 0.6) saying:
error: inappropriate types: expected &TPoint , but found @TPoint (attribute store is different: expected, but found @)
Is this a bug in the compiler? Or are borrowed pointers not allowed for features?
If the answer is the last, why?
source share