我有这段代码,但它给了我一个我不明白的错误:
\nfn main() {\n // --snip--\n\n let mut unit = String::new();\n\n std::io::stdin()\n .read_line(&mut unit)\n .expect("couldn\'t read line!");\n\n let unit = unit.trim().to_lowercase();\n dbg!(unit);\n\n if unit == "f" {\n println!("temperature in Celsius is : {}\xc2\xb0c", f_to_c(temp));\n } else if unit == "c" {\n println!("temperature in Fahrenheit is : {}\xc2\xb0f", c_to_f(temp));\n } else {\n println!("\'{unit}\' unit not supported!");\n }\n}\nRun Code Online (Sandbox Code Playgroud)\nerror[E0382]: borrow of moved value: `unit`\n --> src/lib.rs:16:8\n |\n13 | let unit = unit.trim().to_lowercase();\n | ---- move occurs because `unit` has type …Run Code Online (Sandbox Code Playgroud) 这是提交之间的区别,只是注释和行间距不同,但旧的提交正常运行,而新的结果导致段错误:
Binary files a/recover/recover and b/recover/recover differ
diff --git a/recover/recover.c b/recover/recover.c
index f0ffdf6..02ab42b 100644
--- a/recover/recover.c
+++ b/recover/recover.c
@@ -1,34 +1,32 @@
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
typedef enum
{
- false,
- true
-} bool;
+ true,
+ false
-typedef uint8_t BYTE;
+} bool;
typedef char *string;
+typedef uint8_t BYTE;
int BLOCK_SIZE = 512;
int main(int argc, char *argv[])
{
- // Check if a file name was provided as an argument
- if …Run Code Online (Sandbox Code Playgroud)