Use smartstring for name of field (#819). (#899)

Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
This commit is contained in:
André Isaksson Kraft 2021-03-30 07:29:08 +02:00 committed by GitHub
parent 61fbd6ef7f
commit 0de631741e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 6 deletions

View file

@ -46,6 +46,7 @@ graphql-parser = { version = "0.3", optional = true }
indexmap = { version = "1.0", features = ["serde-1"] }
serde = { version = "1.0.8", features = ["derive"], default-features = false }
serde_json = { version = "1.0.2", default-features = false, optional = true }
smartstring = "0.2.6"
static_assertions = "1.1"
url = { version = "2.0", optional = true }
uuid = { version = "0.8", default-features = false, optional = true }

View file

@ -1158,7 +1158,7 @@ where
T: GraphQLType<S> + ?Sized,
{
Field {
name: name.to_owned(),
name: smartstring::SmartString::from(name),
description: None,
arguments: None,
field_type: self.get_type::<T>(info),
@ -1176,7 +1176,7 @@ where
I: GraphQLType<S>,
{
Field {
name: name.to_owned(),
name: smartstring::SmartString::from(name),
description: None,
arguments: None,
field_type: self.get_type::<I>(info),

View file

@ -297,7 +297,7 @@ impl<'a> Lexer<'a> {
}
// Make sure we are on a valid char boundary.
let escape = &self
let escape = self
.source
.get(start_idx..=end_idx)
.ok_or_else(|| Spanning::zero_width(&self.position, LexerError::UnterminatedString))?;

View file

@ -158,7 +158,7 @@ pub enum MetaType<'a, S = DefaultScalarValue> {
#[derive(Debug, Clone)]
pub struct Field<'a, S> {
#[doc(hidden)]
pub name: String,
pub name: smartstring::alias::String,
#[doc(hidden)]
pub description: Option<String>,
#[doc(hidden)]

View file

@ -318,8 +318,8 @@ impl<'a, S> Field<'a, S>
where
S: crate::ScalarValue + 'a,
{
fn name(&self) -> &String {
&self.name
fn name(&self) -> String {
self.name.clone().into()
}
fn description(&self) -> &Option<String> {