solidity/test/libsolidity/semanticTests/libraries/using_for_storage_structs.sol

26 lines
426 B
Solidity
Raw Normal View History

struct Struct { uint x; }
library L {
function f(Struct storage _x) internal view returns (uint256) {
return _x.x;
}
}
contract C {
using L for Struct;
Struct s;
function h(Struct storage _s) internal view returns (uint) {
// _s is pointer
return _s.f();
}
function g() public returns (uint, uint) {
s.x = 7;
// s is reference
return (s.f(), h(s));
}
}
// ----
// g() -> 7, 7