Add a Counter.reset function (#2678)

This commit is contained in:
Hadrien Croubois
2021-05-19 20:52:43 +02:00
committed by GitHub
parent c3ae4790c7
commit 8ea06b75aa
5 changed files with 31 additions and 2 deletions

View File

@ -5,7 +5,7 @@ pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
@ -35,4 +35,8 @@ library Counters {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}