Cannot subtract `&NumT` from `&NumT`

What do I need to put into the where clause for the generic NumT so that I can subtract references to NumT?

I'm currently getting the following error:

cannot subtract `&NumT` from `&NumT`

note that both are immutable references.

NumT: SubAssign<&NumT> should work, if you have a &mut NumT

No, these are both immutable references. I don't want to trash any of their values, instead I just want to create a new value.

yep. https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=76ed97718eebdd7f55f1730a476b8e70

Got there in the end:

&'t NumT: Sub<Output = NumT>

does the trick

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.