Hacker News new | ask | show | jobs
by chrismorgan 511 days ago
Interesting that both went for fn(T, T) -> T, with a bound of Add<Output = T>, rather than using a bound of Add and returning T::Output, which is of very similar complexity, but a bit more general.

You can also make it more flexible still, supporting different argument types, but this is decidedly more verbose:

  fn add<Lhs, Rhs>(lhs: Lhs, rhs: Rhs) -> Lhs::Output where Lhs: Add<Rhs> {
      lhs + rhs
  }