Impl macro for scalars, vol.2 [skip ci]
This commit is contained in:
parent
f2718cc01a
commit
a05a0091f6
2 changed files with 11 additions and 15 deletions
|
@ -4,6 +4,7 @@ use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
collections::{hash_map, HashMap},
|
collections::{hash_map, HashMap},
|
||||||
|
convert,
|
||||||
fmt::{Debug, Display},
|
fmt::{Debug, Display},
|
||||||
sync::{Arc, RwLock},
|
sync::{Arc, RwLock},
|
||||||
};
|
};
|
||||||
|
@ -1297,14 +1298,12 @@ impl<'r, S: 'r> Registry<'r, S> {
|
||||||
T: resolve::TypeName<TI> + resolve::InputValueOwned<S> + resolve::ScalarToken<S>,
|
T: resolve::TypeName<TI> + resolve::InputValueOwned<S> + resolve::ScalarToken<S>,
|
||||||
TI: ?Sized,
|
TI: ?Sized,
|
||||||
'ti: 'r,
|
'ti: 'r,
|
||||||
F: FnOnce(&mut ScalarMeta<'r, S>),
|
F: FnOnce(ScalarMeta<'r, S>) -> ScalarMeta<'r, S>,
|
||||||
S: Clone,
|
S: Clone,
|
||||||
{
|
{
|
||||||
self.entry_type::<T, _>(type_info)
|
self.entry_type::<T, _>(type_info)
|
||||||
.or_insert_with(move || {
|
.or_insert_with(move || {
|
||||||
let mut scalar = ScalarMeta::new_reworked::<T, _>(T::type_name(type_info));
|
customize(ScalarMeta::new_reworked::<T, _>(T::type_name(type_info))).into_meta()
|
||||||
customize(&mut scalar);
|
|
||||||
scalar.into_meta()
|
|
||||||
})
|
})
|
||||||
.clone()
|
.clone()
|
||||||
}
|
}
|
||||||
|
@ -1326,9 +1325,7 @@ impl<'r, S: 'r> Registry<'r, S> {
|
||||||
'ti: 'r,
|
'ti: 'r,
|
||||||
S: Clone,
|
S: Clone,
|
||||||
{
|
{
|
||||||
// TODO: Use `drop` instead of `|_| {}` once Rust's inference becomes
|
self.register_scalar_unsized_with::<T, TI, _>(type_info, convert::identity)
|
||||||
// better for HRTB closures.
|
|
||||||
self.register_scalar_unsized_with::<T, TI, _>(type_info, |_| {})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a [`ScalarMeta`] information for the specified non-[`Sized`]
|
/// Builds a [`ScalarMeta`] information for the specified non-[`Sized`]
|
||||||
|
@ -1351,14 +1348,12 @@ impl<'r, S: 'r> Registry<'r, S> {
|
||||||
T: resolve::TypeName<TI> + resolve::InputValueAsRef<S> + resolve::ScalarToken<S> + ?Sized,
|
T: resolve::TypeName<TI> + resolve::InputValueAsRef<S> + resolve::ScalarToken<S> + ?Sized,
|
||||||
TI: ?Sized,
|
TI: ?Sized,
|
||||||
'ti: 'r,
|
'ti: 'r,
|
||||||
F: FnOnce(&mut ScalarMeta<'r, S>),
|
F: FnOnce(ScalarMeta<'r, S>) -> ScalarMeta<'r, S>,
|
||||||
S: Clone,
|
S: Clone,
|
||||||
{
|
{
|
||||||
self.entry_type::<T, _>(type_info)
|
self.entry_type::<T, _>(type_info)
|
||||||
.or_insert_with(move || {
|
.or_insert_with(move || {
|
||||||
let mut scalar = ScalarMeta::new_unsized::<T, _>(T::type_name(type_info));
|
customize(ScalarMeta::new_unsized::<T, _>(T::type_name(type_info))).into_meta()
|
||||||
customize(&mut scalar);
|
|
||||||
scalar.into_meta()
|
|
||||||
})
|
})
|
||||||
.clone()
|
.clone()
|
||||||
}
|
}
|
||||||
|
|
|
@ -529,7 +529,8 @@ impl Definition {
|
||||||
let predicates = &mut generics.make_where_clause().predicates;
|
let predicates = &mut generics.make_where_clause().predicates;
|
||||||
predicates.push(parse_quote! { #sv: Clone });
|
predicates.push(parse_quote! { #sv: Clone });
|
||||||
predicates.push(parse_quote! {
|
predicates.push(parse_quote! {
|
||||||
Self: ::juniper::resolve::TypeName<#inf, #bh>
|
::juniper::behavior::Coerce<Self, #bh>:
|
||||||
|
::juniper::resolve::TypeName<#inf, #bh>
|
||||||
+ ::juniper::resolve::ScalarToken<#sv, #bh>
|
+ ::juniper::resolve::ScalarToken<#sv, #bh>
|
||||||
+ ::juniper::resolve::InputValueOwned<#sv, #bh>
|
+ ::juniper::resolve::InputValueOwned<#sv, #bh>
|
||||||
});
|
});
|
||||||
|
@ -561,7 +562,7 @@ impl Definition {
|
||||||
::juniper::behavior::Coerce<Self, #bh>, _, _,
|
::juniper::behavior::Coerce<Self, #bh>, _, _,
|
||||||
>(type_info, |meta| {
|
>(type_info, |meta| {
|
||||||
meta#description
|
meta#description
|
||||||
#specified_by_url;
|
#specified_by_url
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue