pub struct FnContract {
pub lang: ForeignLang,
pub name: String,
pub params: Vec<String>,
pub requires: Vec<Term>,
pub ensures: Vec<Term>,
pub retval: Option<Term>,
pub impurity: Option<String>,
pub fields: Vec<(String, Term)>,
}Expand description
The checked contract of one foreign function.
Fields§
§lang: ForeignLangThe language the contract was written in.
name: StringFunction name.
params: Vec<String>Parameter names in declaration order.
requires: Vec<Term>Parsed requires clauses.
ensures: Vec<Term>Parsed ensures clauses.
retval: Option<Term>E from the unique ensures retval == E, over parameters and
constants. None when the function’s return value is unconstrained
or only constrained non-deterministically (a range, a disjunction).
impurity: Option<String>Why calling the function has a side effect, from the reader; None
when none was found.
fields: Vec<(String, Term)>Each field of a struct result fixed by an ensures \result.f == E,
E free of the result, in clause order.
Implementations§
Source§impl FnContract
impl FnContract
Sourcepub fn from_clauses(
lang: ForeignLang,
name: String,
params: Vec<String>,
requires: Vec<Term>,
ensures: Vec<Term>,
impurity: Option<String>,
) -> Result<Self>
pub fn from_clauses( lang: ForeignLang, name: String, params: Vec<String>, requires: Vec<Term>, ensures: Vec<Term>, impurity: Option<String>, ) -> Result<Self>
Assemble a contract from clauses a reader has parsed, deriving its
deterministic return value: the E of a unique retval == E with
E free of retval.
§Errors
A requires that mentions the return value, which only exists after
the call; or two ensures retval == … clauses.
Source§impl FnContract
impl FnContract
Sourcepub fn result_range(&self) -> Option<(i128, i128)>
pub fn result_range(&self) -> Option<(i128, i128)>
The interval the ensures bound the return value to, when they say
only that: no retval == E, and every clause that mentions the
return value compares it with constants under && and ||. None
when unbounded, or when a clause says anything else.
Trait Implementations§
Source§impl Clone for FnContract
impl Clone for FnContract
Source§fn clone(&self) -> FnContract
fn clone(&self) -> FnContract
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more