Created
June 25, 2025 18:38
-
-
Save andrewrk/dd201280ee869d1230dfe1c880a3f1d0 to your computer and use it in GitHub Desktop.
distinct vector types example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub const GlobalVec = UniqueVec(.global); | |
pub const LocalVec = UniqueVec(.local); | |
pub const Tag = enum {global,local}; | |
fn UniqueVec(tag: Tag) type { | |
return struct { | |
pub const tag = Tag; | |
pub fn add(...) @This() { ... } | |
pub fn sub(...) @This() { ... } | |
// ... | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub const GlobalVec = struct {v: Vec}; | |
pub const LocalVec = struct {v: Vec}; | |
pub const Vec = struct { | |
pub fn add(...) @This() { ... } | |
pub fn sub(...) @This() { ... } | |
// ... | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment