what is an idiomatic way to express the close connection between two types, which are basically the same with the only difference being one is owning, one is not?
So my use case is I am parsing a memmapped file, so I have bytes in memory and then I construct views on that memory. Which means I start with the view and not the owner.
Unless I can project the owned type onto the memmapped file?
C++ would let me do such things
As a side note, reading file as &[i32] doesn't seems like a good idea, because that file can be transferred to the machine with different endianness. Most file/network formats enforces big endian to handle this portability problem. The only major format I know that doesn't follows this practice is UTF-16 which is mostly used within MS windows. They inserts BOM(Byte Order Mark) character at the start of every UTF-16 file to detect the file's endianness. But it makes parsing a bit harder, you can easily find a realm of BOM-haters on the internet.