Skip to content

Expanding let $ident:$ty = $expr; #5

Closed
@tathanhdinh

Description

@tathanhdinh

Hello all,

Currently, if_chain refuses to expand the pattern let $ident:$ty = $expr;, for example this piece of code

if_chain! {
  if false;
  let y: u32 = 4;

  then {
    ...
  } else {
    ...
  }
};

will not compile. I try to add a rule to support this pattern as:

(@expand $other:block let $ident:ident:$ty:ty = $expr:expr; $($tt:tt)+) => {
  let $ident:$ty = $expr;
  __if_chain! { @expand $other $($tt)+ }
};

but I don't know whether there is a better way to do that or if_chain is interested in supporting this pattern.

Many thanks for any comment.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions