When programming generics, I very commonly stumble across the situation like following:
pub fn Pair(First_: type, Second_: type) type {
return struct {
// It's more important to have properly named public decls,
// so use the underscores for the generic's parameters rather than here.
pub const First = First_;
pub const Second = Second_;
first: First,
second: Second,
};
}
Using underscores looks ugly, but it is the best solution pattern which I have managed to invent so far. E.g. using FirstType and SecondType for the generic's parameters looks just like a longer version of the underscore, more confusing than adding to the readability. I was wondering whether there any better approaches?