On Fri, Dec 9, 2011 at 4:08 AM, Marijn Haverbeke <[email protected]> wrote: >> 2. Inferring the type of 'x' in "let x = []" is neat, but is this type >> of inference a privilege restricted to the builtin types? > > No. 'let x = none;' also works (and none is defined as a regular sum > type in the stdlib).
I'm not sure that's equivalent. If you remove the syntactic sugar, this: let x = []; Is basically this: let x = List<MysteryT>(); Where MysteryT gets inferred based on what's put in the container. I'm sure if I write: let x = none; x = List<Int>(); That it will work, but I'm less confident that this will work for user types: let x = MyContainer<MysteryT>(); x.insert(3); // now infer that x is really a MyContainer<int> How would the compiler infer that? _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
