pub struct DependentType {
pub base_type: String,
pub type_params: Vec<String>,
pub dim_params: Vec<DimExpr>,
pub name: Option<String>,
pub description: Option<String>,
pub constraints: Vec<DimConstraint>,
}Expand description
A dependent type with dimension parameters.
Fields§
§base_type: StringBase type name
type_params: Vec<String>Type parameters (other types)
dim_params: Vec<DimExpr>Dimension parameters
name: Option<String>Optional name for the dependent type
description: Option<String>Description
constraints: Vec<DimConstraint>Constraints between dimensions
Implementations§
Source§impl DependentType
impl DependentType
Sourcepub fn vector(element_type: impl Into<String>, length: DimExpr) -> Self
pub fn vector(element_type: impl Into<String>, length: DimExpr) -> Self
Create a vector type with a dimension.
Sourcepub fn matrix(
element_type: impl Into<String>,
rows: DimExpr,
cols: DimExpr,
) -> Self
pub fn matrix( element_type: impl Into<String>, rows: DimExpr, cols: DimExpr, ) -> Self
Create a matrix type with dimensions.
Sourcepub fn tensor(element_type: impl Into<String>, dims: Vec<DimExpr>) -> Self
pub fn tensor(element_type: impl Into<String>, dims: Vec<DimExpr>) -> Self
Create a tensor type with arbitrary dimensions.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set the description.
Sourcepub fn with_type_param(self, param: impl Into<String>) -> Self
pub fn with_type_param(self, param: impl Into<String>) -> Self
Add a type parameter.
Sourcepub fn with_dim_param(self, dim: DimExpr) -> Self
pub fn with_dim_param(self, dim: DimExpr) -> Self
Add a dimension parameter.
Sourcepub fn with_constraint(self, constraint: DimConstraint) -> Self
pub fn with_constraint(self, constraint: DimConstraint) -> Self
Add a dimension constraint.
Sourcepub fn eval_shape(&self, ctx: &DependentTypeContext) -> Option<Vec<usize>>
pub fn eval_shape(&self, ctx: &DependentTypeContext) -> Option<Vec<usize>>
Evaluate the shape of this type in a context.
Sourcepub fn free_variables(&self) -> Vec<String>
pub fn free_variables(&self) -> Vec<String>
Get all free dimension variables.
Sourcepub fn check_constraints(
&self,
ctx: &DependentTypeContext,
) -> Result<(), String>
pub fn check_constraints( &self, ctx: &DependentTypeContext, ) -> Result<(), String>
Check if constraints are satisfied in a context.
Sourcepub fn is_compatible_with(
&self,
other: &DependentType,
ctx: &DependentTypeContext,
) -> bool
pub fn is_compatible_with( &self, other: &DependentType, ctx: &DependentTypeContext, ) -> bool
Check if this type is compatible with another for assignment.
Trait Implementations§
Source§impl Clone for DependentType
impl Clone for DependentType
Source§fn clone(&self) -> DependentType
fn clone(&self) -> DependentType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DependentType
impl RefUnwindSafe for DependentType
impl Send for DependentType
impl Sync for DependentType
impl Unpin for DependentType
impl UnwindSafe for DependentType
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