fn find_ref<'a>(
    id: &usize, 
    locals: &'a HashMap<usize, Object>, 
    globals: &'a HashMap<usize, Object>,
    identifiers: &HashMap<usize, String>
) -> Option<&'a Object> {
    if let Some(obj) = locals.get(&id) {
        if let Type::Reference(reference) = obj.obj_type {
            find_ref(&reference.pointer, locals, globals, identifiers)
        }
        else {
            Some(obj)
        }
    }
    else if let Some(obj) = globals.get(&id) {
        if let Type::Reference(reference) = obj.obj_type {
            find_ref(&reference.pointer, locals, globals, identifiers)
        }
        else {
            Some(obj)
        }
    }
    else {
        throw_error(
            ErrorType::ObjectNotDefinedError, 
            format!("Object {} is not defined in the local or global scopes", id),
            Some((&[*id], identifiers))
        );
        None
    }
}
/// Searches for an object in the locals and globals provided. 
/// If found, returns a reference to the object.
/// If not found, throws an error and returns None. 
Searches for an object in the locals and globals provided.
If found, returns a reference to the object.
If not found, throws an error and returns None.
Searches for an object in the locals and globals provided . If found returns a reference to the object . If not found throws an error and returns None .
fn find_ref<'a>(
    id: &usize, 
    locals: &'a HashMap<usize, Object>, 
    globals: &'a HashMap<usize, Object>,
    identifiers: &HashMap<usize, String>
) -> Option<&'a Object> {
    if let Some(obj) = locals.get(&id) {
        if let Type::Reference(reference) = obj.obj_type {
            find_ref(&reference.pointer, locals, globals, identifiers)
        }
        else {
            Some(obj)
        }
    }
    else if let Some(obj) = globals.get(&id) {
        if let Type::Reference(reference) = obj.obj_type {
            find_ref(&reference.pointer, locals, globals, identifiers)
        }
        else {
            Some(obj)
        }
    }
    else {
        throw_error(
            ErrorType::ObjectNotDefinedError, 
            format!("Object {} is not defined in the local or global scopes", id),
            Some((&[*id], identifiers))
        );
        None
    }
}
fn find_ref < ' a > ( id : & usize , locals : & ' a HashMap < usize , Object > , globals : & ' a HashMap < usize , Object > , identifiers : & HashMap < usize , String > ) -> Option < & ' a Object > { if let Some ( obj ) = locals . get ( & id ) { if let Type :: Reference ( reference ) = obj . obj_type { find_ref ( & reference . pointer , locals , globals , identifiers ) } else { Some ( obj ) } } else if let Some ( obj ) = globals . get ( & id ) { if let Type :: Reference ( reference ) = obj . obj_type { find_ref ( & reference . pointer , locals , globals , identifiers ) } else { Some ( obj ) } } else { throw_error ( ErrorType :: ObjectNotDefinedError , format ! ( " " id ) , Some ( ( & [ * id ] , identifiers ) ) ) ; None } }
Searches for an object in the locals and globals provided.
Searches for an object in the locals and globals provided .
id
&usize
locals
&'a HashMap<usize, Object>
globals
&'a HashMap<usize, Object>
identifiers
&HashMap<usize, String>
id
&usize
locals
&'a HashMap<usize, Object>
globals
&'a HashMap<usize, Object>
identifiers
&HashMap<usize, String>