Enum apollo_compiler::ast::Type
source · pub enum Type {
Named(NamedType),
NonNullNamed(NamedType),
List(Box<Type>),
NonNullList(Box<Type>),
}
Variants§
Implementations§
source§impl Type
impl Type
sourcepub fn item_type(&self) -> &Self
pub fn item_type(&self) -> &Self
If the type is a list type or a non-null list type, return the item type.
Example
use apollo_compiler::ty;
// Returns the inner type of the list.
assert_eq!(ty!([Foo!]).item_type(), &ty!(Foo!));
// Not a list: returns the input.
assert_eq!(ty!(Foo!).item_type(), &ty!(Foo!));
sourcepub fn inner_named_type(&self) -> &NamedType
pub fn inner_named_type(&self) -> &NamedType
Returns the inner named type, after unwrapping any non-null or list markers.
sourcepub fn is_non_null(&self) -> bool
pub fn is_non_null(&self) -> bool
Returns whether this type is non-null
pub fn is_named(&self) -> bool
sourcepub fn is_assignable_to(&self, target: &Self) -> bool
pub fn is_assignable_to(&self, target: &Self) -> bool
Can a value of this type be used when the target
type is expected?
Implementation of spec function AreTypesCompatible()
.
sourcepub fn parse(
source_text: impl Into<String>,
path: impl AsRef<Path>
) -> Result<Self, DiagnosticList>
pub fn parse( source_text: impl Into<String>, path: impl AsRef<Path> ) -> Result<Self, DiagnosticList>
Parse the given source text as a reference to a type.
path
is the filesystem path (or arbitrary string) used in diagnostics
to identify this source file to users.
Create a Parser
to use different parser configuration.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Type
impl<'de> Deserialize<'de> for Type
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq for Type
impl PartialEq for Type
impl Eq for Type
impl StructuralEq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnwindSafe for Type
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.