Created
October 8, 2020 20:34
-
-
Save jlowry/d0c195be09cfb2c91f6408d1e3ea7130 to your computer and use it in GitHub Desktop.
Genna's efficient tuple lookups with some unsafe-but-not-really memory manipulation.
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
// It copies only the string headers (no more expensive than two &str copies) | |
// It's unsafe but only a little type trick to make the HashMap work properly with tuple keys | |
let owned: ManuallyDrop<(String, String)> = | |
ManuallyDrop::new(unsafe {(mem::read(my_ref.0), mem::read(my_ref.1))}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment