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`