Skip to content

Built-in character operators #5922

@jonmeow

Description

@jonmeow

Summary of issue:

Following up on #5903, another question about characters: what operators should Char support, and what should their return values be?

Details:

For background, in #1964, it says (summarizing):

  • Comparison: <, >, <=, >= ==
  • Arithmetic: +, -
  • Explicit conversions to integers, no implicit
    • No statement on conversions from integers.

It gives an example using these in rationale:

var b: u8;
b = 'a' + 1;
b + 1 == 'c';

This example implies the two operator behaviors:

  • 'a' + 1 returns u8 (because there's no implicit conversion from an integer)
  • Comparison between u8 and Char works.

However, other parts of the proposal seem to suggest that neither of those operators should work that way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    leads questionA question for the leads team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions