From 8b530ebc123a114c58c80778265e188e1e9f780b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Meier?= Date: Thu, 2 Nov 2023 14:55:38 +0100 Subject: [PATCH] Return slice in `LookAheadMethods::children()` instead of `Vec` (#1200) --- juniper/CHANGELOG.md | 2 ++ juniper/src/executor/look_ahead.rs | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/juniper/CHANGELOG.md b/juniper/CHANGELOG.md index c68fdc6ac..e21ee3a45 100644 --- a/juniper/CHANGELOG.md +++ b/juniper/CHANGELOG.md @@ -52,6 +52,7 @@ All user visible changes to `juniper` crate will be documented in this file. Thi - Removed `scalar-naivetime` [Cargo feature]. - Removed lifetime parameter from `ParseError`, `GraphlQLError`, `GraphQLBatchRequest` and `GraphQLRequest`. ([#1081], [#528]) - Upgraded [GraphiQL] to 3.0.8 version (requires new [`graphql-transport-ws` GraphQL over WebSocket Protocol] integration on server, see `juniper_warp/examples/subscription.rs`). ([#1188], [#1193], [#1203]) +- Made `LookAheadMethods::children()` method to return slice instead of `Vec`. ([#1200]) ### Added @@ -128,6 +129,7 @@ All user visible changes to `juniper` crate will be documented in this file. Thi [#1190]: /../../pull/1190 [#1193]: /../../pull/1193 [#1199]: /../../pull/1199 +[#1200]: /../../pull/1200 [#1203]: /../../pull/1203 [ba1ed85b]: /../../commit/ba1ed85b3c3dd77fbae7baf6bc4e693321a94083 [CVE-2022-31173]: /../../security/advisories/GHSA-4rx6-g5vg-5f3j diff --git a/juniper/src/executor/look_ahead.rs b/juniper/src/executor/look_ahead.rs index f4b41792c..54643db7c 100644 --- a/juniper/src/executor/look_ahead.rs +++ b/juniper/src/executor/look_ahead.rs @@ -372,7 +372,9 @@ pub trait LookAheadMethods<'sel, S> { fn child_names(&self) -> Vec<&'sel str>; /// Returns an [`Iterator`] over the children from the current selection. - fn children(&self) -> Vec<&Self>; + fn children(&self) -> &[Self] + where + Self: Sized; /// Returns the parent type, in case there is any for the current selection. fn applies_for(&self) -> Option<&str>; @@ -411,8 +413,8 @@ impl<'a, S> LookAheadMethods<'a, S> for ConcreteLookAheadSelection<'a, S> { !self.children.is_empty() } - fn children(&self) -> Vec<&Self> { - self.children.iter().collect() + fn children(&self) -> &[Self] { + &self.children } fn applies_for(&self) -> Option<&str> { @@ -456,8 +458,8 @@ impl<'a, S> LookAheadMethods<'a, S> for LookAheadSelection<'a, S> { !self.children.is_empty() } - fn children(&self) -> Vec<&Self> { - self.children.iter().collect() + fn children(&self) -> &[Self] { + &self.children } fn applies_for(&self) -> Option<&str> {