feat: new builtins constr_index and constr_fields for alternative fast ways to take apart Data

This commit is contained in:
microproofs
2024-12-13 14:15:19 +07:00
parent ebc7d89d5d
commit 463b88413e
7 changed files with 227 additions and 77 deletions

View File

@@ -1448,6 +1448,17 @@ impl Term<Name> {
Term::unconstr_data().apply(std::mem::replace(arg, Term::Error.force())),
)
}
} else if let Term::Lambda {
parameter_name,
body,
} = Rc::make_mut(function)
{
if parameter_name.text == CONSTR_INDEX_EXPOSER
|| parameter_name.text == CONSTR_FIELDS_EXPOSER
{
let body = Rc::make_mut(body);
*self = std::mem::replace(body, Term::Error)
}
}
}
}