pub struct RefinementType {
pub var_name: String,
pub base_type: ParametricType,
pub refinement: TLExpr,
}Expand description
Refinement type: base type with a refinement predicate.
Fields§
§var_name: StringVariable name
base_type: ParametricTypeBase type
refinement: TLExprRefinement predicate on the variable
Implementations§
Source§impl RefinementType
impl RefinementType
pub fn new( var_name: impl Into<String>, base_type: impl Into<String>, refinement: TLExpr, ) -> Self
Sourcepub fn from_parametric(
var_name: impl Into<String>,
base_type: ParametricType,
refinement: TLExpr,
) -> Self
pub fn from_parametric( var_name: impl Into<String>, base_type: ParametricType, refinement: TLExpr, ) -> Self
Create a refinement type from parametric type
Sourcepub fn positive_int(var_name: impl Into<String>) -> Self
pub fn positive_int(var_name: impl Into<String>) -> Self
Positive integers: {x: Int | x > 0}
Sourcepub fn probability(var_name: impl Into<String>) -> Self
pub fn probability(var_name: impl Into<String>) -> Self
Probability: {x: Float | x >= 0.0 && x <= 1.0}
Sourcepub fn non_empty_vec(
var_name: impl Into<String>,
element_type: impl Into<String>,
) -> Self
pub fn non_empty_vec( var_name: impl Into<String>, element_type: impl Into<String>, ) -> Self
Non-empty vector: {v: Vec<T> | length(v) > 0}
Sourcepub fn free_vars(&self) -> HashSet<String>
pub fn free_vars(&self) -> HashSet<String>
Get free variables in the refinement (excluding the refined variable)
Sourcepub fn is_subtype_of(&self, other: &RefinementType) -> bool
pub fn is_subtype_of(&self, other: &RefinementType) -> bool
Check if this type is a subtype of another
Sourcepub fn weaken(&self) -> RefinementType
pub fn weaken(&self) -> RefinementType
Weaken the refinement (make it less restrictive)
Sourcepub fn strengthen(&self, additional: TLExpr) -> RefinementType
pub fn strengthen(&self, additional: TLExpr) -> RefinementType
Strengthen the refinement (add more constraints)
Trait Implementations§
Source§impl Clone for RefinementType
impl Clone for RefinementType
Source§fn clone(&self) -> RefinementType
fn clone(&self) -> RefinementType
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 moreSource§impl Debug for RefinementType
impl Debug for RefinementType
Source§impl<'de> Deserialize<'de> for RefinementType
impl<'de> Deserialize<'de> for RefinementType
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 Display for RefinementType
impl Display for RefinementType
Source§impl PartialEq for RefinementType
impl PartialEq for RefinementType
Source§impl Serialize for RefinementType
impl Serialize for RefinementType
impl StructuralPartialEq for RefinementType
Auto Trait Implementations§
impl Freeze for RefinementType
impl RefUnwindSafe for RefinementType
impl Send for RefinementType
impl Sync for RefinementType
impl Unpin for RefinementType
impl UnwindSafe for RefinementType
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