The expression using Library for type
allows us to use a syntaxsyntactic sugar when using certain functions forfrom the library. It is not required, but it makemakes the contract more readable.
For example, SafeMath had
library SafeMath {
function add(uint256 a, uint256 b) public pure returns (uint256) {
// some unimportant details here
}
}
Then you could use in a contract
function (uint256 x, uint256 y) public pure returns (uint256) {
returns add(x, y);
}
You can add using SafeMath for uint256
function (uint256 x, uint256 y) public pure returns (uint256) {
returns x.add(y);
}
It isn't much per se, but it has a syntax close to calling a methodsmethod from an object.