Skip to content

Instantly share code, notes, and snippets.

@BUNotesAI
Last active February 4, 2025 07:33
Show Gist options
  • Select an option

  • Save BUNotesAI/636d8cc62ccaea186d9b5e98d298036b to your computer and use it in GitHub Desktop.

Select an option

Save BUNotesAI/636d8cc62ccaea186d9b5e98d298036b to your computer and use it in GitHub Desktop.
rust常用小工具 tools
/// rust tools
fn main() {
get_variable_type();
}
///get any variable type
fn get_variable_type() {
//expected (), found reference
let v: () = "hello world";
//expected (), found struct `std::string::String`
let v2: () = "hello world".to_string();
//expected (), found &str
let x = "Hello world";
let v3: () = x;
//expected (), found &&str
let y = "Hello world";
let v4: () = &y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment