fn decl_dependencies(&self, decl: &Decl) -> Result<HashSet<&Decl>, ParseError> {
        let mut edges = HashSet::new();

        let mut maybe_add_decl = |ty, ignore_ref| {
            if let Some(type_decl) = self.type_to_decl(ty, ignore_ref) {
                match type_decl {
                    // FIDL omits dependencies on protocols.
                    Decl::Protocol { .. } => (),
                    _ => {
                        edges.insert(type_decl);
                    }
                }
            }
        };

        match decl {
            Decl::Protocol { placeholders, .. } => {
                for placeholder in placeholders {
                    maybe_add_decl(&placeholder, false);
                }
            }
            Decl::Struct { fields, .. } => {
                for field in fields {
                    maybe_add_decl(&field.ty, true);
                }
            }
            Decl::Union { fields, .. } => {
                for field in fields {
                    maybe_add_decl(&field.ty, true);
                }
            }
            Decl::Alias(_to, from) => {
                maybe_add_decl(&self.id_to_type(from), false);
            }
            Decl::Constant { ty, .. } => {
                maybe_add_decl(&ty, false);
            }
            // Enum cannot have dependencies.
            Decl::Enum { .. } => (),
            Decl::Resource { .. } => (),
        };

        Ok(edges)
    }
// An edge from D1 to D2 means that a C needs to see the declaration
// of D1 before the declaration of D2. For instance, given the banjo
//     struct D2 { D1 d; };
//     struct D1 { int32 x; };
// D1 has an edge pointing to D2. Note that struct and union pointers,
// unlike inline structs or unions, do not have dependency edges.
An edge from D1 to D2 means that a C needs to see the declaration
of D1 before the declaration of D2. For instance, given the banjo
struct D2 { D1 d; };
struct D1 { int32 x; };
D1 has an edge pointing to D2. Note that struct and union pointers,
unlike inline structs or unions, do not have dependency edges.
An edge from D1 to D2 means that a C needs to see the declaration of D1 before the declaration of D2 . For instance given the banjo struct D2 { D1 d ; } ; struct D1 { int32 x ; } ; D1 has an edge pointing to D2 . Note that struct and union pointers unlike inline structs or unions do not have dependency edges .
fn decl_dependencies(&self, decl: &Decl) -> Result<HashSet<&Decl>, ParseError> {
        let mut edges = HashSet::new();
        let mut maybe_add_decl = |ty, ignore_ref| {
            if let Some(type_decl) = self.type_to_decl(ty, ignore_ref) {
                match type_decl {
                    // FIDL omits dependencies on protocols.
                    Decl::Protocol { .. } => (),
                    _ => {
                        edges.insert(type_decl);
                    }
                }
            }
        };
        match decl {
            Decl::Protocol { placeholders, .. } => {
                for placeholder in placeholders {
                    maybe_add_decl(&placeholder, false);
                }
            }
            Decl::Struct { fields, .. } => {
                for field in fields {
                    maybe_add_decl(&field.ty, true);
                }
            }
            Decl::Union { fields, .. } => {
                for field in fields {
                    maybe_add_decl(&field.ty, true);
                }
            }
            Decl::Alias(_to, from) => {
                maybe_add_decl(&self.id_to_type(from), false);
            }
            Decl::Constant { ty, .. } => {
                maybe_add_decl(&ty, false);
            }
            // Enum cannot have dependencies.
            Decl::Enum { .. } => (),
            Decl::Resource { .. } => (),
        };
        Ok(edges)
    }
fn decl_dependencies ( & self , decl : & Decl ) -> Result < HashSet < & Decl > , ParseError > { let mut edges = HashSet :: new ( ) ; let mut maybe_add_decl = | ty , ignore_ref | { if let Some ( type_decl ) = self . type_to_decl ( ty , ignore_ref ) { match type_decl { // FIDL omits dependencies on protocols. Decl :: Protocol { .. } => ( ) , _ => { edges . insert ( type_decl ) ; } } } } ; match decl { Decl :: Protocol { placeholders , .. } => { for placeholder in placeholders { maybe_add_decl ( & placeholder , false ) ; } } Decl :: Struct { fields , .. } => { for field in fields { maybe_add_decl ( & field . ty , true ) ; } } Decl :: Union { fields , .. } => { for field in fields { maybe_add_decl ( & field . ty , true ) ; } } Decl :: Alias ( _to , from ) => { maybe_add_decl ( & self . id_to_type ( from ) , false ) ; } Decl :: Constant { ty , .. } => { maybe_add_decl ( & ty , false ) ; } // Enum cannot have dependencies. Decl :: Enum { .. } => ( ) , Decl :: Resource { .. } => ( ) , } ; Ok ( edges ) }
An edge from D1 to D2 means that a C needs to see the declaration
of D1 before the declaration of D2.
An edge from D1 to D2 means that a C needs to see the declaration of D1 before the declaration of D2 .
&self
decl
&Decl
&self
decl
&Decl