ITADN

Feature request: HashIndex::retain_async() where predicate is a Future

#207Opencspoelstra 创建于 2025-11-14
enhancement
C
cspoelstracommented
Hello, I have a use case where I need to call an async function, in order to determine wheter or not to retain elements in a HashIndex. So I would like to be be able to do something such as the following: ``` use scc::HashIndex; async fn my_retain(v: &i32) -> bool { *v == 10 } #[tokio::main] async fn main() { let hash_index = HashIndex::new(); hash_index.insert_async(1, 10).await.unwrap(); hash_index.insert_async(2, 20).await.unwrap(); hash_index.retain_async(async |k, v| my_retain(v).await) } ``` This is not currently possible since `retain_async` requires the closure to be FnMut.
0 条评论