luaur-analysis 0.1.3

Luau type checker and type inference (Rust).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Node: `cxx:Method:Luau.Analysis:Analysis/include/Luau/Set.h:55:set_erase`
//! Source: `Analysis/include/Luau/Set.h:55-65` (hand-ported)

use crate::records::set::Set;

impl<T: Clone + core::hash::Hash + PartialEq> Set<T> {
    /// C++ `void erase(T&& element)` / `void erase(const T& element)` —
    /// tombstones the entry (sets it false) rather than removing the slot.
    pub fn erase(&mut self, element: &T) {
        let entry = self.mapping.get_or_insert(element.clone());

        if *entry {
            *entry = false;
            self.entry_count -= 1;
        }
    }
}