Skip to content

Commit

Permalink
Return slice in LookAheadMethods::children() instead of Vec (#1200)
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenmeier authored Nov 2, 2023
1 parent da005fc commit 8b530eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions juniper/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions juniper/src/executor/look_ahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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> {
Expand Down

0 comments on commit 8b530eb

Please sign in to comment.