/// Return the field in from a record.
Return the field in from a record.
Return the field in from a record .
pub fn eval_record_elim(record: Rc<Value>, label: &Label) -> Result<Rc<Value>, String> {
    match record.as_ref() {
        Value::RecordIntro(fields) => match fields.iter().find(|(l, _)| l == label) {
            Some((_, term)) => Ok(term.clone()),
            None => Err(format!(
                "eval_record_elim: field `{}` not found in record",
                label.0,
            )),
        },
        Value::Neutral(head, spine) => {
            let mut spine = spine.clone();
            spine.push(Elim::Record(label.clone()));
            // TODO: If head is `primitive`, and arity == number of initial spine apps in NF
            Ok(Rc::from(Value::Neutral(head.clone(), spine)))
        },
        _ => Err("eval_record_elim: not a record".to_owned()),
    }
}
pub fn eval_record_elim ( record : Rc < Value > , label : & Label ) -> Result < Rc < Value > , String > { match record . as_ref ( ) { Value :: RecordIntro ( fields ) => match fields . iter ( ) . find ( | ( l , _ ) | l == label ) { Some ( ( _ , term ) ) => Ok ( term . clone ( ) ) , None => Err ( format ! ( " " label 0 ) ) , } , Value :: Neutral ( head , spine ) => { let mut spine = spine . clone ( ) ; spine . push ( Elim :: Record ( label . clone ( ) ) ) ; // TODO: If head is `primitive`, and arity == number of initial spine apps in NF Ok ( Rc :: from ( Value :: Neutral ( head . clone ( ) , spine ) ) ) } , _ => Err ( " " . to_owned ( ) ) , } }
Return the field in from a record.
Return the field in from a record .
record
Rc<Value>
label
&Label