Enum prqlc_ast::TyKind

source ·
pub enum TyKind {
    Ident(Ident),
    Primitive(PrimitiveSet),
    Singleton(Literal),
    Union(Vec<(Option<String>, Ty)>),
    Tuple(Vec<TupleField>),
    Array(Box<Ty>),
    Function(Option<TyFunc>),
    Any,
    Difference {
        base: Box<Ty>,
        exclude: Box<Ty>,
    },
    GenericArg((usize, String)),
}

Variants§

§

Ident(Ident)

Identifier that still needs to be resolved.

§

Primitive(PrimitiveSet)

Type of a built-in primitive type

§

Singleton(Literal)

Type that contains only a one value

§

Union(Vec<(Option<String>, Ty)>)

Union of sets (sum)

§

Tuple(Vec<TupleField>)

Type of tuples (product)

§

Array(Box<Ty>)

Type of arrays

§

Function(Option<TyFunc>)

Type of functions with defined params and return types.

§

Any

Type of every possible value. Super type of all other types. The breaker of chains. Mother of types.

§

Difference

Fields

§base: Box<Ty>
§exclude: Box<Ty>

Type that is the largest subtype of base while not a subtype of exclude.

§

GenericArg((usize, String))

A generic argument. Contains id of the function call node and generic type param name.

Implementations§

source§

impl TyKind

source

pub fn is_ident(&self) -> bool

Returns true if this is a TyKind::Ident, otherwise false

source

pub fn as_ident_mut(&mut self) -> Option<&mut Ident>

Optionally returns mutable references to the inner fields if this is a TyKind::Ident, otherwise None

source

pub fn as_ident(&self) -> Option<&Ident>

Optionally returns references to the inner fields if this is a TyKind::Ident, otherwise None

source

pub fn into_ident(self) -> Result<Ident, Self>

Returns the inner fields if this is a TyKind::Ident, otherwise returns back the enum in the Err case of the result

source

pub fn is_primitive(&self) -> bool

Returns true if this is a TyKind::Primitive, otherwise false

source

pub fn as_primitive_mut(&mut self) -> Option<&mut PrimitiveSet>

Optionally returns mutable references to the inner fields if this is a TyKind::Primitive, otherwise None

source

pub fn as_primitive(&self) -> Option<&PrimitiveSet>

Optionally returns references to the inner fields if this is a TyKind::Primitive, otherwise None

source

pub fn into_primitive(self) -> Result<PrimitiveSet, Self>

Returns the inner fields if this is a TyKind::Primitive, otherwise returns back the enum in the Err case of the result

source

pub fn is_singleton(&self) -> bool

Returns true if this is a TyKind::Singleton, otherwise false

source

pub fn as_singleton_mut(&mut self) -> Option<&mut Literal>

Optionally returns mutable references to the inner fields if this is a TyKind::Singleton, otherwise None

source

pub fn as_singleton(&self) -> Option<&Literal>

Optionally returns references to the inner fields if this is a TyKind::Singleton, otherwise None

source

pub fn into_singleton(self) -> Result<Literal, Self>

Returns the inner fields if this is a TyKind::Singleton, otherwise returns back the enum in the Err case of the result

source

pub fn is_union(&self) -> bool

Returns true if this is a TyKind::Union, otherwise false

source

pub fn as_union_mut(&mut self) -> Option<&mut Vec<(Option<String>, Ty)>>

Optionally returns mutable references to the inner fields if this is a TyKind::Union, otherwise None

source

pub fn as_union(&self) -> Option<&Vec<(Option<String>, Ty)>>

Optionally returns references to the inner fields if this is a TyKind::Union, otherwise None

source

pub fn into_union(self) -> Result<Vec<(Option<String>, Ty)>, Self>

Returns the inner fields if this is a TyKind::Union, otherwise returns back the enum in the Err case of the result

source

pub fn is_tuple(&self) -> bool

Returns true if this is a TyKind::Tuple, otherwise false

source

pub fn as_tuple_mut(&mut self) -> Option<&mut Vec<TupleField>>

Optionally returns mutable references to the inner fields if this is a TyKind::Tuple, otherwise None

source

pub fn as_tuple(&self) -> Option<&Vec<TupleField>>

Optionally returns references to the inner fields if this is a TyKind::Tuple, otherwise None

source

pub fn into_tuple(self) -> Result<Vec<TupleField>, Self>

Returns the inner fields if this is a TyKind::Tuple, otherwise returns back the enum in the Err case of the result

source

pub fn is_array(&self) -> bool

Returns true if this is a TyKind::Array, otherwise false

source

pub fn as_array_mut(&mut self) -> Option<&mut Box<Ty>>

Optionally returns mutable references to the inner fields if this is a TyKind::Array, otherwise None

source

pub fn as_array(&self) -> Option<&Box<Ty>>

Optionally returns references to the inner fields if this is a TyKind::Array, otherwise None

source

pub fn into_array(self) -> Result<Box<Ty>, Self>

Returns the inner fields if this is a TyKind::Array, otherwise returns back the enum in the Err case of the result

source

pub fn is_function(&self) -> bool

Returns true if this is a TyKind::Function, otherwise false

source

pub fn as_function_mut(&mut self) -> Option<&mut Option<TyFunc>>

Optionally returns mutable references to the inner fields if this is a TyKind::Function, otherwise None

source

pub fn as_function(&self) -> Option<&Option<TyFunc>>

Optionally returns references to the inner fields if this is a TyKind::Function, otherwise None

source

pub fn into_function(self) -> Result<Option<TyFunc>, Self>

Returns the inner fields if this is a TyKind::Function, otherwise returns back the enum in the Err case of the result

source

pub fn is_any(&self) -> bool

Returns true if this is a TyKind::Any, otherwise false

source

pub fn is_difference(&self) -> bool

Returns true if this is a TyKind::Difference, otherwise false

source

pub fn as_difference_mut(&mut self) -> Option<(&mut Box<Ty>, &mut Box<Ty>)>

Optionally returns mutable references to the inner fields if this is a TyKind::Difference, otherwise None

source

pub fn as_difference(&self) -> Option<(&Box<Ty>, &Box<Ty>)>

Optionally returns references to the inner fields if this is a TyKind::Difference, otherwise None

source

pub fn into_difference(self) -> Result<(Box<Ty>, Box<Ty>), Self>

Returns the inner fields if this is a TyKind::Difference, otherwise returns back the enum in the Err case of the result

source

pub fn is_generic_arg(&self) -> bool

Returns true if this is a TyKind::GenericArg, otherwise false

source

pub fn as_generic_arg_mut(&mut self) -> Option<&mut (usize, String)>

Optionally returns mutable references to the inner fields if this is a TyKind::GenericArg, otherwise None

source

pub fn as_generic_arg(&self) -> Option<&(usize, String)>

Optionally returns references to the inner fields if this is a TyKind::GenericArg, otherwise None

source

pub fn into_generic_arg(self) -> Result<(usize, String), Self>

Returns the inner fields if this is a TyKind::GenericArg, otherwise returns back the enum in the Err case of the result

Trait Implementations§

source§

impl AsRef<str> for TyKind

source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for TyKind

source§

fn clone(&self) -> TyKind

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TyKind

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for TyKind

source§

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 From<Literal> for TyKind

source§

fn from(value: Literal) -> Self

Converts to this type from the input type.
source§

impl From<PrimitiveSet> for TyKind

source§

fn from(value: PrimitiveSet) -> Self

Converts to this type from the input type.
source§

impl From<TyFunc> for TyKind

source§

fn from(value: TyFunc) -> Self

Converts to this type from the input type.
source§

impl PartialEq for TyKind

source§

fn eq(&self, other: &TyKind) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for TyKind

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for TyKind

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,