Skip to content

Commit 8b530eb

Browse files
authored
Return slice in LookAheadMethods::children() instead of Vec (#1200)
1 parent da005fc commit 8b530eb

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

juniper/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
5252
- Removed `scalar-naivetime` [Cargo feature].
5353
- Removed lifetime parameter from `ParseError`, `GraphlQLError`, `GraphQLBatchRequest` and `GraphQLRequest`. ([#1081], [#528])
5454
- 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])
55+
- Made `LookAheadMethods::children()` method to return slice instead of `Vec`. ([#1200])
5556

5657
### Added
5758

@@ -128,6 +129,7 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
128129
[#1190]: /../../pull/1190
129130
[#1193]: /../../pull/1193
130131
[#1199]: /../../pull/1199
132+
[#1200]: /../../pull/1200
131133
[#1203]: /../../pull/1203
132134
[ba1ed85b]: /../../commit/ba1ed85b3c3dd77fbae7baf6bc4e693321a94083
133135
[CVE-2022-31173]: /../../security/advisories/GHSA-4rx6-g5vg-5f3j

juniper/src/executor/look_ahead.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,9 @@ pub trait LookAheadMethods<'sel, S> {
372372
fn child_names(&self) -> Vec<&'sel str>;
373373

374374
/// Returns an [`Iterator`] over the children from the current selection.
375-
fn children(&self) -> Vec<&Self>;
375+
fn children(&self) -> &[Self]
376+
where
377+
Self: Sized;
376378

377379
/// Returns the parent type, in case there is any for the current selection.
378380
fn applies_for(&self) -> Option<&str>;
@@ -411,8 +413,8 @@ impl<'a, S> LookAheadMethods<'a, S> for ConcreteLookAheadSelection<'a, S> {
411413
!self.children.is_empty()
412414
}
413415

414-
fn children(&self) -> Vec<&Self> {
415-
self.children.iter().collect()
416+
fn children(&self) -> &[Self] {
417+
&self.children
416418
}
417419

418420
fn applies_for(&self) -> Option<&str> {
@@ -456,8 +458,8 @@ impl<'a, S> LookAheadMethods<'a, S> for LookAheadSelection<'a, S> {
456458
!self.children.is_empty()
457459
}
458460

459-
fn children(&self) -> Vec<&Self> {
460-
self.children.iter().collect()
461+
fn children(&self) -> &[Self] {
462+
&self.children
461463
}
462464

463465
fn applies_for(&self) -> Option<&str> {

0 commit comments

Comments
 (0)