1
let c1 = || { "c1"; };
let c2 = || { "c2"; };
let v = [c1, c2];
let v: Vec<fn()> = vec![c1, c2];
let v = vec![1, 2, 3];

Why the compiler cannot automatically infer the type of v in the fourth line of the code, but needs to be explicitly specified. But the fifth line can automatically infer the type of v

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
iDuanYingJie
  • 663
  • 4
  • 11

0 Answers0