/// Allocates a new node in this trie (with all children empty) and returns
/// its ID.
Allocates a new node in this trie (with all children empty) and returns
its ID.
Allocates a new node in this trie ( with all children empty ) and returns its ID .
fn alloc_node(&mut self) -> TrieNodeID {
        // This is correct since we assume that there are no more than
        // 2^32/NODE_SIZE trie nodes. In practice, for this challenge, it
        // works.
        let id = self.counts.len().checked_mul(NODE_SIZE).unwrap();
        // This is correct since new() allocates space for a dummy node, so
        // self.counts.len() is always at least 1 and thus id is always greater
        // than 0.
        let id = TrieNodeID::new(u32::try_from(id).unwrap()).unwrap();
        self.nodes.extend(std::iter::repeat(None).take(NODE_SIZE));
        self.counts.push(0);
        id
    }
fn alloc_node ( & mut self ) -> TrieNodeID { // This is correct since we assume that there are no more than // 2^32/NODE_SIZE trie nodes. In practice, for this challenge, it // works. let id = self . counts . len ( ) . checked_mul ( NODE_SIZE ) . unwrap ( ) ; // This is correct since new() allocates space for a dummy node, so // self.counts.len() is always at least 1 and thus id is always greater // than 0. let id = TrieNodeID :: new ( u32 :: try_from ( id ) . unwrap ( ) ) . unwrap ( ) ; self . nodes . extend ( std :: iter :: repeat ( None ) . take ( NODE_SIZE ) ) ; self . counts . push ( 0 ) ; id }
Allocates a new node in this trie (with all children empty) and returns
its ID.
Allocates a new node in this trie ( with all children empty ) and returns its ID .
&mut self