Hello rust hackers,
In section 8.1.7 of the Rust manual ("Recursive types"), there is an
example of a List definition which is recursive. Here I define a very
simple arithmetic expression which consists of numbers and add
expressions. When I compile it I get errors..
enum Expr
{
Num(int),
Add(@Expr, @Expr),
}
fn eval(e: Expr) -> int {
match e {
Num(x) => x,
Add(x, y) => eval(x) + eval(y),
}
}
fn main() {
println(format!("eval 2 = {:d}", eval(Num(2))));
println(format!("eval 2 + 3 = {:d}", eval(Add(Num(2), Num(3)))));
}
$ rustc arith.rs
arith.rs:4:8: 4:13 error: The managed box syntax may be replaced by a
library type, and a garbage collector is not yet implemented. Consider
using the `std::rc` module as it performs much better as a reference
counting implementation.
arith.rs:4 Add(@Expr, @Expr),
^~~~~
arith.rs:4:8: 4:13 note: add #[feature(managed_boxes)] to the crate
attributes to enable
arith.rs:4 Add(@Expr, @Expr),
^~~~~
arith.rs:4:15: 4:20 error: The managed box syntax may be replaced by a
library type, and a garbage collector is not yet implemented. Consider
using the `std::rc` module as it performs much better as a reference
counting implementation.
arith.rs:4 Add(@Expr, @Expr),
^~~~~
arith.rs:4:15: 4:20 note: add #[feature(managed_boxes)] to the crate
attributes to enable
arith.rs:4 Add(@Expr, @Expr),
^~~~~
error: aborting due to 2 previous errors
I am running rust from master. What exactly is the compiler suggesting
me to do? How can `std::rc' module help in this situation?
TIA
--
Ramakrishnan
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev