This file contains 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
use std::mem; | |
// Example of a module that loads a tagged union from a raw byte slice. | |
// The tagged union consists of a 32-bit type field, followed by fields whose types and count | |
// depend on the tag | |
// | |
// The goal is to take a byte slice and return a ref to the appropriate struct depending on | |
// the tag, or an error in case of overflow of the buffer or unknown tag | |
// | |
// I know this doesn't handle endianness. My full implementation does, but I've removed it to |