mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
using-for-rst: Make it clearer where snippets are just examples
This commit is contained in:
parent
c2e6452b90
commit
abbf2cb6d6
@ -16,14 +16,14 @@ at contract level.
|
|||||||
|
|
||||||
The first part, ``A``, can be one of:
|
The first part, ``A``, can be one of:
|
||||||
|
|
||||||
- A list of file-level or library functions (``using {f, g, h, L.t} for uint;``) -
|
- A list of file-level or library functions (e.g. ``using {f, g, h, L.t} for uint;``) -
|
||||||
only those functions will be attached to the type as member functions.
|
only those functions will be attached to the type as member functions.
|
||||||
Note that private library functions can only be specified when ``using for`` is inside the library.
|
Note that private library functions can only be specified when ``using for`` is inside the library.
|
||||||
- The name of a library (``using L for uint;``) -
|
- The name of a library (e.g. ``using L for uint;``) -
|
||||||
all non-private functions of the library are attached to the type.
|
all non-private functions of the library are attached to the type.
|
||||||
|
|
||||||
At file level, the second part, ``B``, has to be an explicit type (without data location specifier).
|
At file level, the second part, ``B``, has to be an explicit type (without data location specifier).
|
||||||
Inside contracts, you can also use ``using L for *;``,
|
Inside contracts, you can also use ``*`` in place of the type (e.g. ``using L for *;``),
|
||||||
which has the effect that all functions of the library ``L``
|
which has the effect that all functions of the library ``L``
|
||||||
are attached to *all* types.
|
are attached to *all* types.
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ match the type of the object. The type is checked at the
|
|||||||
point the function is called and function overload
|
point the function is called and function overload
|
||||||
resolution is performed.
|
resolution is performed.
|
||||||
|
|
||||||
If you use a list of functions (``using {f, g, h, L.t} for uint;``),
|
If you use a list of functions (e.g. ``using {f, g, h, L.t} for uint;``),
|
||||||
then the type (``uint``) has to be implicitly convertible to the
|
then the type (``uint``) has to be implicitly convertible to the
|
||||||
first parameter of each of these functions. This check is
|
first parameter of each of these functions. This check is
|
||||||
performed even if none of these functions are called.
|
performed even if none of these functions are called.
|
||||||
|
Loading…
Reference in New Issue
Block a user