Comment

Comment by akavel

Newbie question: in the last example:

  fn make_tester(answer: &str) -> impl Fn(&str) -> bool + '_ {
      move |challenge| {
          challenge == answer
      }
  }
why is there `move` needed, if both `answer`, and the arg of `Fn`, seem to be references (`&str`)? To a layman, this sounds like as if both "challenge" and "answer" should be borrowed - so why "move"? what's even to move here?
parent akavel 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton