Created
December 11, 2015 08:38
-
-
Save kondrak/b7351f11ce8b5950d423 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/ ** This doesn't work ** / | |
//let class_name = to_wstring("minifb_window"); | |
/ ** However calling to_wstring() code not from within external function DOES! **/ | |
let v: Vec<u16> = OsStr::new("minifb_window").encode_wide().chain(Some(0).into_iter()).collect(); | |
let class_name = v.as_ptr(); | |
Possible explanation (see definition of as_ptr()): https://doc.rust-lang.org/std/vec/struct.Vec.html | |
"The caller must ensure that the slice outlives the pointer this function returns, or else it will end up pointing to garbage." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment