pub struct ParametricType {
pub constructor: String,
pub parameters: Vec<TypeParameter>,
}Expand description
A parameterized domain type with type parameters.
Examples:
List<Person>- A list of personsOption<City>- An optional cityPair<Person, City>- A pair of person and cityMap<String, Int>- A mapping from strings to integers
Fields§
§constructor: StringThe type constructor name (e.g., “List”, “Option”, “Pair”)
parameters: Vec<TypeParameter>The type parameters (e.g., ["Person"] for List<Person>)
Implementations§
Source§impl ParametricType
impl ParametricType
Sourcepub fn new(
constructor: impl Into<String>,
parameters: Vec<TypeParameter>,
) -> Self
pub fn new( constructor: impl Into<String>, parameters: Vec<TypeParameter>, ) -> Self
Creates a new parametric type with the given constructor and parameters.
Sourcepub fn list(inner: TypeParameter) -> Self
pub fn list(inner: TypeParameter) -> Self
Creates a List<T> parametric type.
Sourcepub fn option(inner: TypeParameter) -> Self
pub fn option(inner: TypeParameter) -> Self
Creates an Option<T> parametric type.
Sourcepub fn pair(first: TypeParameter, second: TypeParameter) -> Self
pub fn pair(first: TypeParameter, second: TypeParameter) -> Self
Creates a Pair<A, B> parametric type.
Sourcepub fn map(key: TypeParameter, value: TypeParameter) -> Self
pub fn map(key: TypeParameter, value: TypeParameter) -> Self
Creates a Map<K, V> parametric type.
Sourcepub fn validate(&self) -> Result<(), AdapterError>
pub fn validate(&self) -> Result<(), AdapterError>
Validates that the parametric type is well-formed.
Checks:
- Constructor name is not empty
- Number of parameters matches expected arity for known constructors
- All nested parametric types are also well-formed
Sourcepub fn arity(&self) -> usize
pub fn arity(&self) -> usize
Returns the arity (number of type parameters) of this parametric type.
Sourcepub fn is_monomorphic(&self) -> bool
pub fn is_monomorphic(&self) -> bool
Checks if this is a monomorphic type (no type parameters).
Sourcepub fn contains_parameter(&self, name: &str) -> bool
pub fn contains_parameter(&self, name: &str) -> bool
Checks if this parametric type contains the given type parameter name.
Sourcepub fn substitute(&self, from: &str, to: &TypeParameter) -> ParametricType
pub fn substitute(&self, from: &str, to: &TypeParameter) -> ParametricType
Substitutes all occurrences of a type parameter with a concrete type.
This is used for type instantiation when applying a parametric type to concrete arguments.
Trait Implementations§
Source§impl Clone for ParametricType
impl Clone for ParametricType
Source§fn clone(&self) -> ParametricType
fn clone(&self) -> ParametricType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParametricType
impl Debug for ParametricType
Source§impl<'de> Deserialize<'de> for ParametricType
impl<'de> Deserialize<'de> for ParametricType
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>,
Source§impl Display for ParametricType
impl Display for ParametricType
Source§impl Hash for ParametricType
impl Hash for ParametricType
Source§impl PartialEq for ParametricType
impl PartialEq for ParametricType
Source§impl Serialize for ParametricType
impl Serialize for ParametricType
impl Eq for ParametricType
impl StructuralPartialEq for ParametricType
Auto Trait Implementations§
impl Freeze for ParametricType
impl RefUnwindSafe for ParametricType
impl Send for ParametricType
impl Sync for ParametricType
impl Unpin for ParametricType
impl UnwindSafe for ParametricType
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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
key and return true if they are equal.