Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading 拼接方法类型不匹配_Multithreading_Rust_Mutex - Fatal编程技术网

Multithreading 拼接方法类型不匹配

Multithreading 拼接方法类型不匹配,multithreading,rust,mutex,Multithreading,Rust,Mutex,所以我有一个布尔向量,隐藏在互斥体的弧后面: let mut vec: Arc<Mutex<Vec<bool>>> = Arc::new(Mutex::new(vec![false; size])); segment(见最后一行)是在线程中创建的std::vec::vec 希望我的意图是明确的 但是,我遇到了以下错误: type mismatch resolving `<std::slice::Iter<'_, bool> as IntoI

所以我有一个布尔向量,隐藏在互斥体的弧后面:

let mut vec: Arc<Mutex<Vec<bool>>> = Arc::new(Mutex::new(vec![false; size]));
segment
(见最后一行)是在线程中创建的
std::vec::vec

希望我的意图是明确的

但是,我遇到了以下错误:

type mismatch resolving `<std::slice::Iter<'_, bool> as IntoIterator>::Item == bool`

data.splice(min..=max, segment.iter().clone()).collect();
     ^^^^^^ expected reference, found `bool`

note: expected reference `&bool`
found type `bool`

类型不匹配解析`您不小心用克隆了迭代器。您可能打算调用,以便迭代器克隆其项

data.splice(min..=max,segment.iter().cloned()).collect();
type mismatch resolving `<std::slice::Iter<'_, bool> as IntoIterator>::Item == bool`

data.splice(min..=max, segment.iter().clone()).collect();
     ^^^^^^ expected reference, found `bool`

note: expected reference `&bool`
found type `bool`