Skip to content

Commit

Permalink
Merge branch 'main' into 01-15-fix_gossip_contact-info_cache_oob
Browse files Browse the repository at this point in the history
  • Loading branch information
dnut authored Jan 16, 2025
2 parents 18974ad + bfcd3bd commit e194073
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ There are two main guidelines to keep in mind when naming interfaces and interfa
- As an example, a generic implementation of `std.Random` which is a pseudo-random number generator should be named `prng` (ie this is relevant when making appropriate use of `std.Random.DefaultPrng`).
- As another example, an instance of `std.heap.GeneralPurposeAllocator(config)` should be called `gpa_state`, `std.heap.ArenaAllocator` `arena_state`, and so on.

#### Method Parameters
The first parameter of a method should be named `self`. The type should be the name of the struct.
For example:

```zig
const MyStruct = struct {
state: u8,
fn write(self: *MyStruct, new_state: u8) void {
self.state = new_state;
}
};
```

If the type name is not available (for example in anonymous structs), define `const Self = @This()`
and use that as the type.

### Files as Structs
We prohibit usage of files as instantiable struct types in the codebase.

Expand Down

0 comments on commit e194073

Please sign in to comment.