Last active
February 4, 2025 07:33
-
-
Save BUNotesAI/636d8cc62ccaea186d9b5e98d298036b to your computer and use it in GitHub Desktop.
rust常用小工具 tools
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
| /// 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