graphql-rust / juniper

GraphQL server library for Rust
Other
5.69k stars 422 forks source link

refactor: Avoid copying Span when evaluating rules #1242

Closed audunhalland closed 8 months ago

audunhalland commented 8 months ago

As mentioned in https://github.com/graphql-rust/juniper/pull/1209#discussion_r1388107123, making Spanning generic over Sp allows avoiding copying 6 usizes (the Span) in places where a borrowed Spanning needs to be type mapped. I.e. the Document contains Spanning<InputValue>, but InputValue is an enum, so when the spanned item's type gets mapped into a reference to each variant, there's no need to transform &Spanning<T, Span> to Spanning<&U, Span>. It can instead be transformed to a Spanning<&U, &Span>.

This applies to the Visitor trait and its methods related to the visitation of InputValues. The Visitor trait is public, but #[doc(hidden)].