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
//cargo.toml | |
//[dependencies] | |
//winapi = { version = "0.3.9", features = ["minwindef","winuser"] } | |
//[lib] | |
//crate-type = ["cdylib"] | |
//lib.rs | |
#![cfg(windows)] | |
use std::ptr::null_mut; |
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::ffi::c_void; | |
use std::ptr; | |
type Error = u32; | |
type FnMessageBox = extern "stdcall" fn(hWnd: *const c_void, lpText: *const u16, lpCaption: *const u16, uType: u32) -> i32; | |
#[link(name = "kernel32")] | |
#[no_mangle] | |
extern "stdcall" { | |
fn GetLastError() -> Error; |
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
//Ref https://gist.github.com/jimmychu0807/9a89355e642afad0d2aeda52e6ad2424 | |
use std::str; | |
fn main() { | |
// -- FROM: vec of chars -- | |
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}']; | |
// to String | |
let string1: String = src1.iter().collect::<String>(); | |
// to str | |
let str1: &str = &src1.iter().collect::<String>(); |