/// Merges the selection sets of several fields into a single selection set.
Merges the selection sets of several fields into a single selection set.
Merges the selection sets of several fields into a single selection set .
fn merge_selection_sets(fields: Vec<&q::Field>) -> q::SelectionSet {
    let (span, items) = fields
        .iter()
        .fold((None, vec![]), |(span, mut items), field| {
            (
                // The overal span is the min/max spans of all merged selection sets
                match span {
                    None => Some(field.selection_set.span),
                    Some((start, end)) => Some((
                        cmp::min(start, field.selection_set.span.0),
                        cmp::max(end, field.selection_set.span.1),
                    )),
                },
                // The overall selection is the result of merging the selections of all fields
                {
                    items.extend_from_slice(field.selection_set.items.as_slice());
                    items
                },
            )
        });
    q::SelectionSet {
        span: span.unwrap(),
        items,
    }
}
fn merge_selection_sets ( fields : Vec < & q :: Field > ) -> q :: SelectionSet { let ( span , items ) = fields . iter ( ) . fold ( ( None , vec ! [ ] ) , | ( span , mut items ) , field | { ( // The overal span is the min/max spans of all merged selection sets match span { None => Some ( field . selection_set . span ) , Some ( ( start , end ) ) => Some ( ( cmp :: min ( start , field . selection_set . span . 0 ) , cmp :: max ( end , field . selection_set . span . 1 ) , ) ) , } , // The overall selection is the result of merging the selections of all fields { items . extend_from_slice ( field . selection_set . items . as_slice ( ) ) ; items } , ) } ) ; q :: SelectionSet { span : span . unwrap ( ) , items , } }
Merges the selection sets of several fields into a single selection set.
Merges the selection sets of several fields into a single selection set .
fields
Vec<&q::Field>