Consider:
const WorkoutSchema = @This();
Out of curiosity, I decided to make the declaration public:
pub const WorkoutSchema = @This();
However it seems that there are no differences.
Is this a case similar to top level comments that are allowed inside namespaces other than the implicit struct created by files?
Thanks
it’s just an alias, that you made public.
1 Like
Like @vulpesx mentioned, its just an alias of the files struct type.
Assuming your file is named WorkoutSchema.zig, you have the following:
const WorkoutSchema = @import("WorkoutSchema.zig");
const WorkoutSchemaAlias = @import("WorkoutSchema.zig").WorkoutSchema // or WorkoutSchema.WorkoutSchema
So you just reexport a type alias of the files struct type, you can access by the name you gave the public constant.
There is no difference, because structs do not really have a name, until you assign them to a named value. So changing the local alias of @This() does not change, how the type can be named importing your file.
But I’m not sure what you mean with the comment question.
2 Likes
Thanks @Sceleton and @vulpesx.
For the comment, ignore it. It was nonsense.
1 Like