error[E0412]: cannot find type `Mutex` in this scope --> src\main.rs:22:29 | 22 | static ref HISTORY_STR: Mutex<String> = Mutex::new(String::new()); | ^^^^^ not found in this scope | help: consider importing one of these items | 怎么解决
这个错误意味着在作用域内找不到 Mutex 类型。您需要在代码中导入该类型。在 Rust 中,您可以使用 use 关键字导入类型。您可以尝试添加以下代码到您的文件的顶部,看看是否能解决问题:
use std::sync::Mutex;
如果您已经导入了 Mutex,请确保您的代码中没有笔误或语法错误。
原文地址: https://www.cveoy.top/t/topic/haW 著作权归作者所有。请勿转载和采集!