pub fn chase_type<'a>(
    seen: &mut BTreeSet<&'a str>,
    res: &mut Vec<&'a str>,
    env: &'a TypeEnv,
    t: &'a Type,
) -> Result<()> {
    use Type::*;
    match t {
        Var(id) => {
            if seen.insert(id) {
                let t = env.find_type(id)?;
                chase_type(seen, res, env, t)?;
                res.push(id);
            }
        }
        Opt(ty) | Vec(ty) => chase_type(seen, res, env, ty)?,
        Record(fs) | Variant(fs) => {
            for f in fs.iter() {
                chase_type(seen, res, env, &f.ty)?;
            }
        }
        Func(f) => {
            for ty in f.args.iter().chain(f.rets.iter()) {
                chase_type(seen, res, env, ty)?;
            }
        }
        Service(ms) => {
            for (_, ty) in ms.iter() {
                chase_type(seen, res, env, ty)?;
            }
        }
        Class(args, t) => {
            for arg in args.iter() {
                chase_type(seen, res, env, arg)?;
            }
            chase_type(seen, res, env, t)?;
        }
        _ => (),
    }
    Ok(())
}
/// Same as chase_actor, with seen set as part of the type. Used for chasing type names from type definitions.
Same as chase_actor, with seen set as part of the type. Used for chasing type names from type definitions.
Same as chase_actor with seen set as part of the type . Used for chasing type names from type definitions .
pub fn chase_type<'a>(
    seen: &mut BTreeSet<&'a str>,
    res: &mut Vec<&'a str>,
    env: &'a TypeEnv,
    t: &'a Type,
) -> Result<()> {
    use Type::*;
    match t {
        Var(id) => {
            if seen.insert(id) {
                let t = env.find_type(id)?;
                chase_type(seen, res, env, t)?;
                res.push(id);
            }
        }
        Opt(ty) | Vec(ty) => chase_type(seen, res, env, ty)?,
        Record(fs) | Variant(fs) => {
            for f in fs.iter() {
                chase_type(seen, res, env, &f.ty)?;
            }
        }
        Func(f) => {
            for ty in f.args.iter().chain(f.rets.iter()) {
                chase_type(seen, res, env, ty)?;
            }
        }
        Service(ms) => {
            for (_, ty) in ms.iter() {
                chase_type(seen, res, env, ty)?;
            }
        }
        Class(args, t) => {
            for arg in args.iter() {
                chase_type(seen, res, env, arg)?;
            }
            chase_type(seen, res, env, t)?;
        }
        _ => (),
    }
    Ok(())
}
pub fn chase_type < ' a > ( seen : & mut BTreeSet < & ' a str > , res : & mut Vec < & ' a str > , env : & ' a TypeEnv , t : & ' a Type , ) -> Result < ( ) > { use Type :: * ; match t { Var ( id ) => { if seen . insert ( id ) { let t = env . find_type ( id ) ? ; chase_type ( seen , res , env , t ) ? ; res . push ( id ) ; } } Opt ( ty ) | Vec ( ty ) => chase_type ( seen , res , env , ty ) ? , Record ( fs ) | Variant ( fs ) => { for f in fs . iter ( ) { chase_type ( seen , res , env , & f . ty ) ? ; } } Func ( f ) => { for ty in f . args . iter ( ) . chain ( f . rets . iter ( ) ) { chase_type ( seen , res , env , ty ) ? ; } } Service ( ms ) => { for ( _ , ty ) in ms . iter ( ) { chase_type ( seen , res , env , ty ) ? ; } } Class ( args , t ) => { for arg in args . iter ( ) { chase_type ( seen , res , env , arg ) ? ; } chase_type ( seen , res , env , t ) ? ; } _ => ( ) , } Ok ( ( ) ) }
Same as chase_actor, with seen set as part of the type.
Same as chase_actor with seen set as part of the type .
seen
&mut BTreeSet<&'a str>
res
&mut Vec<&'a str>
env
&'a TypeEnv
t
&'a Type
seen
&mut BTreeSet<&'a str>
res
&mut Vec<&'a str>
env
&'a TypeEnv
t
&'a Type