Rust : キャスト  構造体 ←→ LPARAM(usize)
pub type LPARAM = usize; struct Context { x : i32, y : i32, } impl Context { pub fn new(pos_x : i32, pos_y : i32) -> Self { Context { x : pos_x, y : pos_y, } } pub fn from_lparam(n : LPARAM) -> &'static mut Self { let p = n as *mut Self; unsafe{ &mut *p } } pub fn to_lparam(&self) -> LPARAM { let p = self as *const Self; p as LPARAM } } fn main() { let ct1 = Context::new( 58, 68 ); println!( "ct1{{ x: {}, y:{} }}", ct1.x, ct1.y ); println!( "ct1 : LPARAM {}", ct1.to_lparam() ); let lpm = ct1.to_lparam(); let ct2 = Context::from_lparam(lpm); println!( "ct2 : LPARAM {}", ct2.to_lparam() ); }