You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: impl_table_types.rs
    path of file: ./repos/mmb/mmb_utils/src
    
    the code of the file until where you have to start completion: use parking_lot::Mutex;
use paste::paste;
use std::collections::HashMap;

use crate::infrastructure::WithExpect;

// Declare methods add_or_get and get_str for structs AppendTable8 and AppendTable16 according to its item bit count
// This types keep items in static tables with fixed sizes
// AppendTable8 (size = 256)
// AppendTable16 (size = 65536)
macro_rules! impl_append_table {
    ($bits: literal) => {
        paste! {
            impl [<AppendTable $bits>] {
                /// Added leaked copy of string to table
                /// Return table index of string equal to specified value if found otherwise create leaked
                /// clone of string, add it to table and return index in table for new value
                pub 
    
                pub fn add_or_get(&self, value: &str) -> [<u $bits>] {
                    let mut inner = self.0.lock();
                    let map = &mut inner.map;

                    if let Some(&index) = map.get(value) {
                        return index;
                    }

                    let count = map.len();
                    let index: [<u $bits>] = count.try_into().with_expect(|| {
                        format!(
                            "For AppendTable{} index {} is greater then {} (map: {:?})",
                            $bits, count, [<u $bits>]::MAX, map
                        )
                    });

                    let static_str: &'static str = Box::leak(value.to_owned().into_boxed_str());

                    let _ = map.insert(static_str, index);

                    let str_ptr = inner
                        .buffer
                        .get_mut(index as usize)
                        .expect("index should be inside because we check it in previous step");
                    *str_ptr = Some(static_str);

                    index
                }