use * for pointer type instead of &
See #770 To help automatically translate code, see the zig-fmt-pointer-reform-2 branch. This will convert all & into *. Due to the syntax ambiguity (which is why we are making this change), even address-of & will turn into *, so you'll have to manually fix thes instances. You will be guaranteed to get compile errors for them - expected 'type', found 'foo'
This commit is contained in:
@@ -9,12 +9,12 @@ pub const BufSet = struct {
|
||||
|
||||
const BufSetHashMap = HashMap([]const u8, void, mem.hash_slice_u8, mem.eql_slice_u8);
|
||||
|
||||
pub fn init(a: &Allocator) BufSet {
|
||||
pub fn init(a: *Allocator) BufSet {
|
||||
var self = BufSet{ .hash_map = BufSetHashMap.init(a) };
|
||||
return self;
|
||||
}
|
||||
|
||||
pub fn deinit(self: &const BufSet) void {
|
||||
pub fn deinit(self: *const BufSet) void {
|
||||
var it = self.hash_map.iterator();
|
||||
while (true) {
|
||||
const entry = it.next() ?? break;
|
||||
@@ -24,7 +24,7 @@ pub const BufSet = struct {
|
||||
self.hash_map.deinit();
|
||||
}
|
||||
|
||||
pub fn put(self: &BufSet, key: []const u8) !void {
|
||||
pub fn put(self: *BufSet, key: []const u8) !void {
|
||||
if (self.hash_map.get(key) == null) {
|
||||
const key_copy = try self.copy(key);
|
||||
errdefer self.free(key_copy);
|
||||
@@ -32,28 +32,28 @@ pub const BufSet = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn delete(self: &BufSet, key: []const u8) void {
|
||||
pub fn delete(self: *BufSet, key: []const u8) void {
|
||||
const entry = self.hash_map.remove(key) ?? return;
|
||||
self.free(entry.key);
|
||||
}
|
||||
|
||||
pub fn count(self: &const BufSet) usize {
|
||||
pub fn count(self: *const BufSet) usize {
|
||||
return self.hash_map.count();
|
||||
}
|
||||
|
||||
pub fn iterator(self: &const BufSet) BufSetHashMap.Iterator {
|
||||
pub fn iterator(self: *const BufSet) BufSetHashMap.Iterator {
|
||||
return self.hash_map.iterator();
|
||||
}
|
||||
|
||||
pub fn allocator(self: &const BufSet) &Allocator {
|
||||
pub fn allocator(self: *const BufSet) *Allocator {
|
||||
return self.hash_map.allocator;
|
||||
}
|
||||
|
||||
fn free(self: &const BufSet, value: []const u8) void {
|
||||
fn free(self: *const BufSet, value: []const u8) void {
|
||||
self.hash_map.allocator.free(value);
|
||||
}
|
||||
|
||||
fn copy(self: &const BufSet, value: []const u8) ![]const u8 {
|
||||
fn copy(self: *const BufSet, value: []const u8) ![]const u8 {
|
||||
const result = try self.hash_map.allocator.alloc(u8, value.len);
|
||||
mem.copy(u8, result, value);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user