File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,25 @@ type ShortString is bytes32;
11
11
* into a `ShortString` type that can be used as an immutable variable.
12
12
* Strings of arbitrary length can be optimized if they are short enough by
13
13
* the addition of a storage variable used as fallback.
14
+ *
15
+ * Usage example:
16
+ *
17
+ * ```solidity
18
+ * contract Named {
19
+ * using ShortStrings for *;
20
+ *
21
+ * ShortString private immutable _name;
22
+ * string private _nameFallback;
23
+ *
24
+ * constructor(string memory contractName) {
25
+ * _name = contractName.toShortStringWithFallback(_nameFallback);
26
+ * }
27
+ *
28
+ * function name() external view returns (string memory) {
29
+ * return _name.toStringWithFallback(_nameFallback);
30
+ * }
31
+ * }
32
+ * ```
14
33
*/
15
34
library ShortStrings {
16
35
error StringTooLong (string str );
You can’t perform that action at this time.
0 commit comments