Programmer in NYC

  • 0 Posts
  • 1 Comment
Joined 1Y ago
cake
Cake day: May 07, 2023

help-circle
rss

Taking a quick look at the changes, most of the changed code is in a block, not a function. I know the argument to Box::pin looks like a function, but it’s actually an async block. So you don’t have a function to return from.

An anonymous function is introduced with an argument list surrounded by pipe characters (|) which you don’t have here. OTOH a block is introduced with curly braces. It is very common to use a block as the body of an anonymous function so it’s easy to mix those up.

A block introduces a new variable scope. It can have keyword modifiers, async and move, as you have here. The entire block is a value which is determined by the last expression in the block.

That’s a long way of saying: delete the return keyword, and remove the semicolon from the same line. That makes the value you want the last expression in the if body, which makes that become the value of the if expression, which then becomes the value of the block.