on writing to: &mut AccountId
, it throws warning to use explicit lifetime name needed here.
#[ink(message)]
pub fn delegate(&mut self, to: &mut AccountId) {
let caller = self.env().caller();
let voters = self.voters.get(caller).unwrap_or_default();
let voters_to = self.voters.get(*to).unwrap_or_default();
assert!(!voters.voted, "You already voted.");
assert!(*to != caller, "Self-delegation is disallowed");
while voters_to.delegate != [0; 32].into() {
*to = voters_to.delegate;
}
}
including lifetime, but it throws ink message must not be generic. I remove #[ink(message)]
and it works fine and #[inline]
as well
#[ink(message)]
pub fn delegate<'a>(&mut self, to: &'a mut AccountId) {
let caller = self.env().caller();
let voters = self.voters.get(caller).unwrap_or_default();
let voters_to = self.voters.get(*to).unwrap_or_default();
assert!(!voters.voted, "You already voted.");
assert!(*to != caller, "Self-delegation is disallowed");
while voters_to.delegate != [0; 32].into() {
*to = voters_to.delegate;
}
}
Anybody explain me why this is happening? Or am I doing something wrong?