Update docs
This commit is contained in:
@ -114,9 +114,9 @@ const toIntDownCast = length => `\
|
||||
*
|
||||
* _Available since v${version('toInt(int)', length)}._
|
||||
*/
|
||||
function toInt${length}(int256 value) internal pure returns (int${length}) {
|
||||
require(value >= type(int${length}).min && value <= type(int${length}).max, "SafeCast: value doesn't fit in ${length} bits");
|
||||
return int${length}(value);
|
||||
function toInt${length}(int256 value) internal pure returns (int${length} downcasted) {
|
||||
downcasted = int${length}(value);
|
||||
require(downcasted == value, "SafeCast: value doesn't fit in ${length} bits");
|
||||
}
|
||||
`;
|
||||
/* eslint-enable max-len */
|
||||
@ -159,10 +159,10 @@ module.exports = format(
|
||||
header.trimEnd(),
|
||||
'library SafeCast {',
|
||||
[
|
||||
...LENGTHS.map(size => toUintDownCast(size)),
|
||||
...LENGTHS.map(toUintDownCast),
|
||||
toUint(256),
|
||||
...LENGTHS.map(size => toIntDownCast(size)),
|
||||
toInt(256).trimEnd(),
|
||||
...LENGTHS.map(toIntDownCast),
|
||||
toInt(256),
|
||||
],
|
||||
'}',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user