Skip to content

Commit d093a52

Browse files
committed
fix fmt
1 parent 76642fc commit d093a52

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/typing/distinct_integers.zig

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55
//! with any number representing an index into `B`, but if we were to,
66
//! for example, access `A` with a number representing an index into `B`,
77
//! we could access garbage information or cause an out of bounds accesss.
8-
//!
8+
//!
99
//! A real world example I've run into while working on ZLS is accidentally
1010
//! swapping `TokenIndex`s and `Ast.Node.Index`s, which are both `= u32`.
11-
//!
11+
//!
1212
//! ```zig
1313
//! pub fn accessANodeNotDistinct(node_index: u32) void {
1414
//! // ...
1515
//! }
16-
//!
16+
//!
1717
//! const token_index_not_a_node: u32 = 10;
1818
//! accessANodeNotDistinct(token_index_not_a_node);
19-
//!
19+
//!
2020
//! // kabloom!
2121
//! ```
22-
//!
22+
//!
2323
//! How can we avoid this? Distinct integers!
2424

2525
const std = @import("std");
2626

27-
pub const TokenIndex = enum(u32) {_};
28-
pub const NodeIndex = enum(u32) {_};
27+
pub const TokenIndex = enum(u32) { _ };
28+
pub const NodeIndex = enum(u32) { _ };
2929

3030
pub fn lastToken() TokenIndex {
3131
return @enumFromInt(0);

0 commit comments

Comments
 (0)