Skip to content

Commit

Permalink
fix(value): value在迭代器中会造成死锁,使用IntoIterator替换Iter
Browse files Browse the repository at this point in the history
  • Loading branch information
yIllusionSky committed Jul 29, 2024
1 parent 647dfda commit 232e3b1
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions gostd/src/net/url/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,21 @@ impl Values {
}
}

impl Iterator for Values {
impl IntoIterator for Values {
type Item = (String, Vec<String>);
type IntoIter = std::collections::hash_map::IntoIter<String, Vec<String>>;

fn next(&mut self) -> Option<Self::Item> {
self.0
.iter()
.next()
.and_then(|(k, v)| Some((k.to_owned(), v.to_owned())))
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}

impl<'a> IntoIterator for &'a Values {
type Item = (&'a String, &'a Vec<String>);
type IntoIter = std::collections::hash_map::Iter<'a, String, Vec<String>>;

fn into_iter(self) -> Self::IntoIter {
self.0.iter()
}
}

Expand Down

0 comments on commit 232e3b1

Please sign in to comment.