pub struct PredicateSignature {
pub name: String,
pub arg_types: Vec<TypeAnnotation>,
pub arity: usize,
pub parametric_types: Option<Vec<ParametricType>>,
}Expand description
Signature for a predicate: defines expected argument types
Fields§
§name: String§arg_types: Vec<TypeAnnotation>§arity: usize§parametric_types: Option<Vec<ParametricType>>Optional parametric type signature for generic predicates
Implementations§
Source§impl PredicateSignature
impl PredicateSignature
pub fn new(name: impl Into<String>, arg_types: Vec<TypeAnnotation>) -> Self
Sourcepub fn parametric(
name: impl Into<String>,
parametric_types: Vec<ParametricType>,
) -> Self
pub fn parametric( name: impl Into<String>, parametric_types: Vec<ParametricType>, ) -> Self
Create a parametric signature
Sourcepub fn untyped(name: impl Into<String>, arity: usize) -> Self
pub fn untyped(name: impl Into<String>, arity: usize) -> Self
Create an untyped signature (for backward compatibility)
Sourcepub fn matches_arity(&self, arg_count: usize) -> bool
pub fn matches_arity(&self, arg_count: usize) -> bool
Check if this signature matches the given number of arguments
Sourcepub fn matches_types(&self, arg_types: &[Option<&TypeAnnotation>]) -> bool
pub fn matches_types(&self, arg_types: &[Option<&TypeAnnotation>]) -> bool
Check if the given argument types match this signature
Sourcepub fn unify_parametric(
&self,
arg_types: &[ParametricType],
) -> Result<TypeSubstitution, IrError>
pub fn unify_parametric( &self, arg_types: &[ParametricType], ) -> Result<TypeSubstitution, IrError>
Unify parametric signature with concrete argument types
Sourcepub fn is_parametric(&self) -> bool
pub fn is_parametric(&self) -> bool
Check if this is a parametric signature
Sourcepub fn get_parametric_types(&self) -> Option<&[ParametricType]>
pub fn get_parametric_types(&self) -> Option<&[ParametricType]>
Get the parametric types if present
Sourcepub fn instantiate(&self, subst: &TypeSubstitution) -> PredicateSignature
pub fn instantiate(&self, subst: &TypeSubstitution) -> PredicateSignature
Instantiate a parametric signature with a substitution
Trait Implementations§
Source§impl Clone for PredicateSignature
impl Clone for PredicateSignature
Source§fn clone(&self) -> PredicateSignature
fn clone(&self) -> PredicateSignature
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 PredicateSignature
impl Debug for PredicateSignature
Source§impl<'de> Deserialize<'de> for PredicateSignature
impl<'de> Deserialize<'de> for PredicateSignature
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 PredicateSignature
impl PartialEq for PredicateSignature
Source§impl Serialize for PredicateSignature
impl Serialize for PredicateSignature
impl Eq for PredicateSignature
impl StructuralPartialEq for PredicateSignature
Auto Trait Implementations§
impl Freeze for PredicateSignature
impl RefUnwindSafe for PredicateSignature
impl Send for PredicateSignature
impl Sync for PredicateSignature
impl Unpin for PredicateSignature
impl UnwindSafe for PredicateSignature
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