Clippy clean

This commit is contained in:
Sunli 2021-05-07 10:14:05 +08:00
parent e10ba3465a
commit deeedf11a6
4 changed files with 13 additions and 17 deletions

View File

@ -51,7 +51,7 @@ impl<T> Positioned<T> {
/// Create a new positioned node from the node and its position. /// Create a new positioned node from the node and its position.
#[must_use] #[must_use]
pub const fn new(node: T, pos: Pos) -> Positioned<T> { pub const fn new(node: T, pos: Pos) -> Positioned<T> {
Positioned { node, pos } Positioned { pos, node }
} }
/// Get the inner node. /// Get the inner node.

View File

@ -38,21 +38,19 @@ impl<'a> __Schema<'a> {
/// If this server supports mutation, the type that mutation operations will be rooted at. /// If this server supports mutation, the type that mutation operations will be rooted at.
#[inline] #[inline]
async fn mutation_type(&self) -> Option<__Type<'a>> { async fn mutation_type(&self) -> Option<__Type<'a>> {
if let Some(ty) = &self.registry.mutation_type { self.registry
Some(__Type::new_simple(self.registry, &self.registry.types[ty])) .mutation_type
} else { .as_ref()
None .map(|ty| __Type::new_simple(self.registry, &self.registry.types[ty]))
}
} }
/// If this server support subscription, the type that subscription operations will be rooted at. /// If this server support subscription, the type that subscription operations will be rooted at.
#[inline] #[inline]
async fn subscription_type(&self) -> Option<__Type<'a>> { async fn subscription_type(&self) -> Option<__Type<'a>> {
if let Some(ty) = &self.registry.subscription_type { self.registry
Some(__Type::new_simple(self.registry, &self.registry.types[ty])) .subscription_type
} else { .as_ref()
None .map(|ty| __Type::new_simple(self.registry, &self.registry.types[ty]))
}
} }
/// A list of all directives supported by this server. /// A list of all directives supported by this server.

View File

@ -17,11 +17,9 @@ use crate::{model, Any, Context, Positioned, ServerResult, Type, Value, VisitorC
pub use cache_control::CacheControl; pub use cache_control::CacheControl;
fn strip_brackets(type_name: &str) -> Option<&str> { fn strip_brackets(type_name: &str) -> Option<&str> {
if let Some(rest) = type_name.strip_prefix('[') { type_name
Some(&rest[..rest.len() - 1]) .strip_prefix('[')
} else { .map(|rest| &rest[..rest.len() - 1])
None
}
} }
#[derive(Clone, Copy, PartialEq, Debug)] #[derive(Clone, Copy, PartialEq, Debug)]

View File

@ -23,8 +23,8 @@ impl<C, T, E> Edge<C, T, E> {
pub fn with_additional_fields(cursor: C, node: T, additional_fields: E) -> Self { pub fn with_additional_fields(cursor: C, node: T, additional_fields: E) -> Self {
Self { Self {
cursor, cursor,
additional_fields,
node, node,
additional_fields,
} }
} }
} }