Skip to content

Commit 63e751e

Browse files
committed
Strip Sized from ToInputValue
1 parent fea4146 commit 63e751e

File tree

7 files changed

+19
-23
lines changed

7 files changed

+19
-23
lines changed

juniper/src/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ pub trait FromInputValue<S = DefaultScalarValue>: Sized {
231231
}
232232
}
233233

234-
/// Losslessly clones a Rust data type into an InputValue.
235-
pub trait ToInputValue<S = DefaultScalarValue>: Sized {
234+
/// Losslessly clones a Rust data type into an [`InputValue`].
235+
pub trait ToInputValue<S = DefaultScalarValue> {
236236
/// Performs the conversion.
237237
fn to_input_value(&self) -> InputValue<S>;
238238
}

juniper/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ pub use crate::{
103103
},
104104
validation::RuleError,
105105
value::{
106-
AnyExt, DefaultScalarValue, FromScalarValue, ToScalarValue, IntoValue, Object,
107-
ParseScalarResult, ParseScalarValue, Scalar, ScalarValue, TryToPrimitive, Value,
106+
AnyExt, DefaultScalarValue, FromScalarValue, IntoValue, Object, ParseScalarResult,
107+
ParseScalarValue, Scalar, ScalarValue, ToScalarValue, TryToPrimitive, Value,
108108
WrongInputScalarTypeError,
109109
},
110110
};

juniper/src/types/containers.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ impl<S, T: FromInputValue<S>> FromInputValue<S> for Option<T> {
9090
}
9191
}
9292

93-
impl<S, T: ToInputValue<S>> ToInputValue<S> for Option<T> {
93+
impl<S, T> ToInputValue<S> for Option<T>
94+
where
95+
T: ToInputValue<S>,
96+
{
9497
fn to_input_value(&self) -> InputValue<S> {
9598
match self {
9699
Some(v) => v.to_input_value(),
@@ -176,7 +179,6 @@ impl<S: ScalarValue, T: FromInputValue<S>> FromInputValue<S> for Vec<T> {
176179
impl<T, S> ToInputValue<S> for Vec<T>
177180
where
178181
T: ToInputValue<S>,
179-
S: ScalarValue,
180182
{
181183
fn to_input_value(&self) -> InputValue<S> {
182184
InputValue::list(self.iter().map(T::to_input_value).collect())
@@ -270,10 +272,9 @@ where
270272
}
271273
}
272274

273-
impl<T, S> ToInputValue<S> for &[T]
275+
impl<T, S> ToInputValue<S> for [T]
274276
where
275277
T: ToInputValue<S>,
276-
S: ScalarValue,
277278
{
278279
fn to_input_value(&self) -> InputValue<S> {
279280
InputValue::list(self.iter().map(T::to_input_value).collect())
@@ -462,7 +463,6 @@ where
462463
impl<T, S, const N: usize> ToInputValue<S> for [T; N]
463464
where
464465
T: ToInputValue<S>,
465-
S: ScalarValue,
466466
{
467467
fn to_input_value(&self) -> InputValue<S> {
468468
InputValue::list(self.iter().map(T::to_input_value).collect())

juniper/src/types/nullable.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,10 @@ impl<S, T: FromInputValue<S>> FromInputValue<S> for Nullable<T> {
302302
impl<S, T> ToInputValue<S> for Nullable<T>
303303
where
304304
T: ToInputValue<S>,
305-
S: ScalarValue,
306305
{
307306
fn to_input_value(&self) -> InputValue<S> {
308-
match *self {
309-
Self::Some(ref v) => v.to_input_value(),
307+
match self {
308+
Self::Some(v) => v.to_input_value(),
310309
_ => InputValue::null(),
311310
}
312311
}

juniper/src/types/pointers.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{fmt, sync::Arc};
1+
use std::sync::Arc;
22

33
use arcstr::ArcStr;
44

@@ -11,7 +11,7 @@ use crate::{
1111
async_await::GraphQLValueAsync,
1212
base::{Arguments, GraphQLType, GraphQLValue},
1313
},
14-
value::{FromScalarValue, ToScalarValue, ScalarValue},
14+
value::{FromScalarValue, ScalarValue, ToScalarValue},
1515
};
1616

1717
impl<S, T> GraphQLType<S> for Box<T>
@@ -122,8 +122,7 @@ where
122122

123123
impl<T, S> ToInputValue<S> for Box<T>
124124
where
125-
S: fmt::Debug,
126-
T: ToInputValue<S>,
125+
T: ToInputValue<S> + ?Sized,
127126
{
128127
fn to_input_value(&self) -> InputValue<S> {
129128
(**self).to_input_value()
@@ -224,8 +223,7 @@ where
224223

225224
impl<T, S> ToInputValue<S> for &T
226225
where
227-
S: fmt::Debug,
228-
T: ToInputValue<S>,
226+
T: ToInputValue<S> + ?Sized,
229227
{
230228
fn to_input_value(&self) -> InputValue<S> {
231229
(**self).to_input_value()
@@ -340,8 +338,7 @@ where
340338

341339
impl<T, S> ToInputValue<S> for Arc<T>
342340
where
343-
S: fmt::Debug,
344-
T: ToInputValue<S>,
341+
T: ToInputValue<S> + ?Sized,
345342
{
346343
fn to_input_value(&self) -> InputValue<S> {
347344
(**self).to_input_value()

juniper/src/types/scalars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ impl<S: ScalarValue> ToScalarValue<S> for str {
317317
}
318318
}
319319

320-
impl<S> ToInputValue<S> for &str
320+
impl<S> ToInputValue<S> for str
321321
where
322322
str: ToScalarValue<S>,
323323
{

juniper/src/value/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use compact_str::CompactString;
99
pub use self::{
1010
object::Object,
1111
scalar::{
12-
AnyExt, DefaultScalarValue, FromScalarValue, ToScalarValue, ParseScalarResult,
13-
ParseScalarValue, Scalar, ScalarValue, TryToPrimitive, WrongInputScalarTypeError,
12+
AnyExt, DefaultScalarValue, FromScalarValue, ParseScalarResult, ParseScalarValue, Scalar,
13+
ScalarValue, ToScalarValue, TryToPrimitive, WrongInputScalarTypeError,
1414
},
1515
};
1616
use crate::{

0 commit comments

Comments
 (0)