try `let i = 0i64` :D it just uses the platform to infer the width by
default. Because number literals show up very commonly throughout Rust
code, its important that we keep them short and unobtrusive by default
though, so its normally just recommended to use the short forum unless you
need a smaller/larger type for some reason.

more detail can be found in the rust reference:
http://doc.rust-lang.org/reference.html#number-literals

On Mon, Nov 3, 2014 at 3:37 PM, Jake Scott <[email protected]> wrote:

> I come from a C# background, so the literal syntax is all new to me. I
> know about type inference but I am being explicit to demonstrate what I
> think is a trap for young players :)
>
> let i: i32 = 0_i32; // uses 'i32' on both sides of the declaration
> let l: u64 = 0_u64; // uses 'u64' on both sides of the declaration
>
> let j: int = 0i; // uses 'int' and 'i' which is different on both sides of
> the declaration
>
>
>
>
>
>
>
>
> On Tue, Nov 4, 2014 at 9:27 AM, Evan G <[email protected]> wrote:
>
>> Also, because you have the type information in the variable, there's no
>> need to redundantly include it by making it an unsigned number literal—rust
>> can infer that information.
>>
>> On Mon, Nov 3, 2014 at 3:25 PM, Evan G <[email protected]> wrote:
>>
>>> Not consistent with what? The syntax for number literals is taken
>>> directly from C/C++, and is used by many other languages.
>>>
>>> On Mon, Nov 3, 2014 at 3:19 PM, Jake Scott <[email protected]> wrote:
>>>
>>>> I was trying to declare a uint using this:
>>>> let a: uint = 0_uint;
>>>>
>>>> But the correct way to declare it is:
>>>> let a: uint = 0u;
>>>>
>>>> Anyone else think that's not consistent?
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Rust-dev mailing list
>>>> [email protected]
>>>> https://mail.mozilla.org/listinfo/rust-dev
>>>>
>>>>
>>>
>>
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to