Consistently name multiple returned values (#5177)
Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
committed by
Hadrien Croubois
parent
22ec876c5a
commit
6c73fcddea
@ -117,21 +117,21 @@ function length(Bytes32ToBytes32Map storage map) internal view returns (uint256)
|
||||
*
|
||||
* - \`index\` must be strictly less than {length}.
|
||||
*/
|
||||
function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32, bytes32) {
|
||||
bytes32 key = map._keys.at(index);
|
||||
return (key, map._values[key]);
|
||||
function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32 key, bytes32 value) {
|
||||
bytes32 atKey = map._keys.at(index);
|
||||
return (atKey, map._values[atKey]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Tries to returns the value associated with \`key\`. O(1).
|
||||
* Does not revert if \`key\` is not in the map.
|
||||
*/
|
||||
function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) {
|
||||
bytes32 value = map._values[key];
|
||||
if (value == bytes32(0)) {
|
||||
function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool exists, bytes32 value) {
|
||||
bytes32 val = map._values[key];
|
||||
if (val == bytes32(0)) {
|
||||
return (contains(map, key), bytes32(0));
|
||||
} else {
|
||||
return (true, value);
|
||||
return (true, val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,18 +213,18 @@ function length(${name} storage map) internal view returns (uint256) {
|
||||
*
|
||||
* - \`index\` must be strictly less than {length}.
|
||||
*/
|
||||
function at(${name} storage map, uint256 index) internal view returns (${keyType}, ${valueType}) {
|
||||
(bytes32 key, bytes32 value) = at(map._inner, index);
|
||||
return (${fromBytes32(keyType, 'key')}, ${fromBytes32(valueType, 'value')});
|
||||
function at(${name} storage map, uint256 index) internal view returns (${keyType} key, ${valueType} value) {
|
||||
(bytes32 atKey, bytes32 val) = at(map._inner, index);
|
||||
return (${fromBytes32(keyType, 'atKey')}, ${fromBytes32(valueType, 'val')});
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Tries to returns the value associated with \`key\`. O(1).
|
||||
* Does not revert if \`key\` is not in the map.
|
||||
*/
|
||||
function tryGet(${name} storage map, ${keyType} key) internal view returns (bool, ${valueType}) {
|
||||
(bool success, bytes32 value) = tryGet(map._inner, ${toBytes32(keyType, 'key')});
|
||||
return (success, ${fromBytes32(valueType, 'value')});
|
||||
function tryGet(${name} storage map, ${keyType} key) internal view returns (bool exists, ${valueType} value) {
|
||||
(bool success, bytes32 val) = tryGet(map._inner, ${toBytes32(keyType, 'key')});
|
||||
return (success, ${fromBytes32(valueType, 'val')});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user