Closed JavedNissar closed 3 years ago
thanks for flagging and i agree that the clone trait seems unnecessary. to make sure i understand your proposal, what would the ideal get_rate interface look like to make this easier for you?
Oh nvm me, 0.4.0
seems to have fixed my issue. What I was proposing in concrete terms was changing the signature of get_rate
from pub fn get_rate(self, from: &T, to: &T) -> Option<ExchangeRate<T>>
to pub fn get_rate(&self, from: &T, to: &T) -> Option<ExchangeRate<T>>
but this seems to have already been resolved.
👍
In it's current form, Exchange.get_rate consumes the exchange on every use which makes it hard to re-use an Exchange throughout a particular section of code. It would be ideal, if exchange.get_rate would borrow itself rather than consume itself when used.
An alternative fix would be to derive the Clone trait for the Exchange struct but I imagine that one would introduce more overhead on use.