I'm trying to represent a keyboard layout (abstractly, a mapping from keys to characters on some keyboard) in Rust. I want to be able to easily access individual keys as well as rows and columns.
This is the sort of data type I'm looking for. This would represent a keyboard layout on a keyboard with four keys arranged in two rows/two columns.
Honestly, I don't understand what the lifetime parameter does, but I needed it to avoid errors. The problem is, I don't even know how to initialize an instance of this struct so that row_1 contains pointers to self.key_top_left and self.key_top_right.
Is there a clean way to initialize this struct? Is there a better approach?