From 232e3b186759a47321f0a45930c1f328277e2e17 Mon Sep 17 00:00:00 2001 From: YaoLinQing Date: Mon, 29 Jul 2024 18:59:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(value):=20value=E5=9C=A8=E8=BF=AD=E4=BB=A3?= =?UTF-8?q?=E5=99=A8=E4=B8=AD=E4=BC=9A=E9=80=A0=E6=88=90=E6=AD=BB=E9=94=81?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E7=94=A8IntoIterator=E6=9B=BF=E6=8D=A2Iter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gostd/src/net/url/mod.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/gostd/src/net/url/mod.rs b/gostd/src/net/url/mod.rs index 3735373..1bac0ca 100644 --- a/gostd/src/net/url/mod.rs +++ b/gostd/src/net/url/mod.rs @@ -347,14 +347,21 @@ impl Values { } } -impl Iterator for Values { +impl IntoIterator for Values { type Item = (String, Vec); + type IntoIter = std::collections::hash_map::IntoIter>; - fn next(&mut self) -> Option { - 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); + type IntoIter = std::collections::hash_map::Iter<'a, String, Vec>; + + fn into_iter(self) -> Self::IntoIter { + self.0.iter() } }