Skip to content

A simpler solution for the macro in "Non-Identifier Identifiers" and terseness/on-topic problem #118

@studyingegret

Description

@studyingegret

Link

Another way to fix this

macro_rules! make_self_mutable {
    ($i:ident) => {let mut $i = self;};
}

is

macro_rules! make_self_mutable {
    ($i:ident, $v:ident) => {let mut $i = $v;};
}

(playground)

And I think the section lacks a conclusion of when self is

  • matched as a ident: always?
  • matched as a pat: never?
  • hygiened as a keyword/identifier: as a keyword unless the incoming context suggests otherwise?

and went on to talk about a lot of failing solutions while the essence of the problem seems to be with contextual matching of self as ident

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions