Created
July 16, 2015 17:05
-
-
Save benaryorg/dffabeb387009036a3eb to your computer and use it in GitHub Desktop.
get the name of the struct of a variable
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
#![feature(core_intrinsics)] | |
struct Something | |
{ | |
data:u32, | |
} | |
impl Something | |
{ | |
pub fn name(&self)->String | |
{ | |
unsafe | |
{ | |
(*std::intrinsics::type_name::<Self>()).to_string() | |
} | |
} | |
} | |
fn main() | |
{ | |
let something=Something{data:0}; | |
println!("{}",something.name()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment