News for hackers. Stuff that matters.
Re:Rust Traits Deep Dive, Part 2 by masklinn on Wednesday June 20, 2018 @07:19AM (#17354289)
> Are there implicit type conversions?

Only implicit refs and derefs I think.

> It's a classic problem in language design. If there are no implicit conversions, users complain about having to write "1.0" instead of "1", or worse, having to write "1.0L".

Rust handles that by type-inferring literals, the literal itself does not impose a type.

If there are no constraints at all I think it defaults to i32. The type can also be provided explicitly as part of the literal e.g. 1f32 or 7u8.

Re:Rust Traits Deep Dive, Part 2 by chrismorgan on Wednesday June 20, 2018 @08:41AM (#17354805)
Note that integer literals and float literals are still distinct; `1` cannot be interpreted as a float, nor can `1.0` be interpreted as an integer—though `1f32` is actually legal (this surprised me; I don’t know when it became legal), while `1.0u32` isn’t.