| ... | @@ -923,21 +923,21 @@ fn foo() i32 { | ... | @@ -923,21 +923,21 @@ fn foo() i32 { |
| 923 | It is also possible to have local variables with static lifetime by using containers inside functions. | 923 | It is also possible to have local variables with static lifetime by using containers inside functions. |
| 924 | </p> | 924 | </p> |
| 925 | {#code_begin|test|static_local_variable#} | 925 | {#code_begin|test|static_local_variable#} |
| 926 | const std = @import("std"); | 926 | const std = @import("std"); |
| 927 | const expect = std.testing.expect; | 927 | const expect = std.testing.expect; |
| 928 | | 928 | |
| 929 | test "static local variable" { | 929 | test "static local variable" { |
| 930 | try expect(foo() == 1235); | 930 | try expect(foo() == 1235); |
| 931 | try expect(foo() == 1236); | 931 | try expect(foo() == 1236); |
| 932 | } | 932 | } |
| 933 | | 933 | |
| 934 | fn foo() i32 { | 934 | fn foo() i32 { |
| 935 | const S = struct { | 935 | const S = struct { |
| 936 | var x: i32 = 1234; | 936 | var x: i32 = 1234; |
| 937 | }; | 937 | }; |
| 938 | S.x += 1; | 938 | S.x += 1; |
| 939 | return S.x; | 939 | return S.x; |
| 940 | } | 940 | } |
| 941 | {#code_end#} | 941 | {#code_end#} |
| 942 | <p> | 942 | <p> |
| 943 | The {#syntax#}extern{#endsyntax#} keyword or {#link|@extern#} builtin function can be used to link against a variable that is exported | 943 | The {#syntax#}extern{#endsyntax#} keyword or {#link|@extern#} builtin function can be used to link against a variable that is exported |