Skip to content

integer literals could be more generic #4169

Description

@thestinger

Right now, integer literals will only be implicitly converted to built-in integer types. This makes it quite verbose to use big integers, even when the initial values can be held within an int. The implicit conversion could be extended to any type implementing the Num trait, since it includes from_int (maybe using an attribute to make the inference optional).

This still doesn't make it as generic as the Num literals in Haskell, which are able to represent a value larger than what an Int can hold - but doing that could wait until Rust has big integer support in the standard library (or built-in, at least for literals).

This also applies to literals like 0.5, which could be used for arbitrary precision floating point types that aren't necessarily in base 2.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions