graph.zig:
const std = @import("std");
const Properties = @import("properties.zig").Properties;
const Vertex = @import("vertex.zig").Vertex;
const Edge = @import("edge.zig").Edge;
// Define the Graph struct with generic properties container
fn Graph(comptime PropsType: type) type {
return struct {
vertices: []Vertex(Properties(PropsType)),
edges: []Edge(Properties(PropsType)),
metadata: []
// Constructor for creating a graph using generics
fn New(comptime PropsType: type) Graph(PropsType) {
return Graph(PropsType){
.vertices = []Vertex(Properties(PropsType)),
.edges = []Edge(Properties(PropsType)),
};
}
};
}
My issue is with fn New(comptime PropType: type), I get an error:
function parameter 'PropsType' shadows function parameter from outer scope
I know I could just change the variable name and use a new variable name instead of PropsType in the New() function, I just want the best zig coding convention advice for implementing generic struct functions.