Search
 
SCRIPT & CODE EXAMPLE
 

RUST

How to know the data type in rust

fn print_type_of<T>(_: &T) {
    println!("{}", std::any::type_name::<T>())
}

fn main() {
    let s = "Hello";
    let i = 42;

    print_type_of(&s); // &str
    print_type_of(&i); // i32
    print_type_of(&main); // playground::main
    print_type_of(&print_type_of::<i32>); // playground::print_type_of<i32>
    print_type_of(&{ || "Hi!" }); // playground::main::{{closure}}
}
Comment

PREVIOUS NEXT
Code Example
Rust :: rust read lines from stdin and return a vec 
Rust :: read file rust 
Rust :: closure rust 
Rust :: rust string from bytes 
Rust :: rust string to f64 
Rust :: length of vector rust 
Rust :: find last element of vec rust 
Rust :: ndarray rust 
Rust :: rust cube root 
Rust :: tcp listener rust 
Rust :: check if an item is in vec in rust 
Rust :: armanriazi•rust•borrowchecker•lifetime•static 
Rust :: rust loop vector by size 
Rust :: hwllo world in rust 
Rust :: armanriazi•rust•error•E0308•mismatched types 
Rust :: armanriazi•rust•dereferencing 
Rust :: minimum and maximum numbers for various integer types 
Rust :: rust how to create array with the same value 
Rust :: armanriazi•rust•comparison•generic•associated type 
Lua :: luau make rainbow part 
Lua :: luau make region3 
Lua :: roblox tween color 
Lua :: roblox table.find 
Lua :: remove from table lua 
Lua :: repeat until in lua 
Lua :: how to access an index of a table lua 
Lua :: while loop in lua 
Lua :: fivem lua set player bucket 
Lua :: check if play is in group 
Matlab :: matlab symbolic derivative 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =