• @[email protected]
    link
    fedilink
    1
    edit-2
    9 months ago

    Note that when you change num to take &self instead, this works out (you also need to mark foo as mutable, of course).

    • @[email protected]
      link
      fedilink
      19 months ago

      It’s a toy example. In that case, the solution is to assign the expression to a variable to compute its result upfront.