Skip to main content

luaur_analysis/functions/
is_subset.rs

1use std::collections::HashSet;
2
3use crate::records::union_type::UnionType;
4use crate::type_aliases::type_id::TypeId;
5
6pub fn is_subset(super_: &UnionType, sub: &UnionType) -> bool {
7    let mut super_types: HashSet<TypeId> = HashSet::new();
8
9    for id in &super_.options {
10        super_types.insert(*id);
11    }
12
13    for id in &sub.options {
14        if !super_types.contains(id) {
15            return false;
16        }
17    }
18
19    true
20}