Skip to content

Commit 0de6317

Browse files
andrisakLegNeato
andauthored
Use smartstring for name of field (#819). (#899)
Co-authored-by: Christian Legnitto <[email protected]>
1 parent 61fbd6e commit 0de6317

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

juniper/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ graphql-parser = { version = "0.3", optional = true }
4646
indexmap = { version = "1.0", features = ["serde-1"] }
4747
serde = { version = "1.0.8", features = ["derive"], default-features = false }
4848
serde_json = { version = "1.0.2", default-features = false, optional = true }
49+
smartstring = "0.2.6"
4950
static_assertions = "1.1"
5051
url = { version = "2.0", optional = true }
5152
uuid = { version = "0.8", default-features = false, optional = true }

juniper/src/executor/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ where
11581158
T: GraphQLType<S> + ?Sized,
11591159
{
11601160
Field {
1161-
name: name.to_owned(),
1161+
name: smartstring::SmartString::from(name),
11621162
description: None,
11631163
arguments: None,
11641164
field_type: self.get_type::<T>(info),
@@ -1176,7 +1176,7 @@ where
11761176
I: GraphQLType<S>,
11771177
{
11781178
Field {
1179-
name: name.to_owned(),
1179+
name: smartstring::SmartString::from(name),
11801180
description: None,
11811181
arguments: None,
11821182
field_type: self.get_type::<I>(info),

juniper/src/parser/lexer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl<'a> Lexer<'a> {
297297
}
298298

299299
// Make sure we are on a valid char boundary.
300-
let escape = &self
300+
let escape = self
301301
.source
302302
.get(start_idx..=end_idx)
303303
.ok_or_else(|| Spanning::zero_width(&self.position, LexerError::UnterminatedString))?;

juniper/src/schema/meta.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub enum MetaType<'a, S = DefaultScalarValue> {
158158
#[derive(Debug, Clone)]
159159
pub struct Field<'a, S> {
160160
#[doc(hidden)]
161-
pub name: String,
161+
pub name: smartstring::alias::String,
162162
#[doc(hidden)]
163163
pub description: Option<String>,
164164
#[doc(hidden)]

juniper/src/schema/schema.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ impl<'a, S> Field<'a, S>
318318
where
319319
S: crate::ScalarValue + 'a,
320320
{
321-
fn name(&self) -> &String {
322-
&self.name
321+
fn name(&self) -> String {
322+
self.name.clone().into()
323323
}
324324

325325
fn description(&self) -> &Option<String> {

0 commit comments

Comments
 (0)