Hello again,

this syntax works.

let list: List<int> = Cons(1, box Cons(2, box Cons(3, box Nil)));

Please disregard my previous e-mail.

Phiroc



Début du message réexpédié :

> De: Philippe de Rochambeau <phi...@free.fr>
> Objet: unexpected token: `)` with new owning-pointer syntax
> Date: 18 mai 2014 10:56:42 UTC+2
> À: rust-dev@mozilla.org
> 
> 
> Hello,
> 
> as a learning exercise, I have converted this code (found here: 
> http://words.steveklabnik.com/pointers-in-rust-a-guide)
> 
> enum List<T> {
>     Nil,
>     Cons(T, ~List<T>),
> }
> 
> fn main() {
>     let list: List<int> = Cons(1, ~Cons(2, ~Cons(3, ~Nil)));
>     println!("{:?}", list);
> }
> to the new Rust 0.11 owning-pointer syntax 
> (http://static.rust-lang.org/doc/master/rust.html#pointer-types):
> 
> enum List<T> {
>     Nil,
>     Cons(T, Box<List<T>>),
> }
> 
> fn main() {
>       // http://words.steveklabnik.com/pointers-in-rust-a-guide
>       // let list: List<int> = Cons(1, ~Cons(2, ~Cons(3, ~Nil)));
>     let list: List<int> =
>               Cons(1,Box<Cons(2,Box<Cons(3,Box<Nil>)>)>);
>               
>     println!("{:?}", list);
> }
> 
> When I compile the above code, I get the following error (although all my 
> opening an closing parentheses seem to match):
> 
> rustc pointer.rs
> pointer.rs:10:40: 10:41 error: unexpected token: `)`
> pointer.rs:10                 Cons(1,Box<Cons(2,Box<Cons(3,Box<Nil>)>)>);
>                                                                    ^
> make: *** [cmp] Error 101
> 
> 
> Am I using the new owning-pointer syntax incorrectly?
> 
> Many thanks.
> 
> Phiroc
> 
> 
> 
> 

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to