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: index_generator.rs
    path of file: ./repos/MoonZoon/crates/zoon/src
    
    the code of the file until where you have to start completion: use crate::*;
use std::{
    collections::BTreeSet,
    sync::atomic::{AtomicU32, Ordering},
    sync::{Arc, RwLock},
};

#[derive(Default)]
pub struct IndexGenerator {
    index: AtomicU32,
    freed: Arc<RwLock<BTreeSet<u32>>>,
}

impl IndexGenerator {
    pub fn new() -> Self {
        Self::defa
    
    pub fn next_index(&self) -> u32 {
        // https://github.com/rust-lang/rust/issues/62924
        let lowest_freed = self.freed.read().unwrap_throw().iter().next().copied();
        if let Some(lowest_freed) = lowest_freed {
            self.freed.write().unwrap_throw().remove(&lowest_freed);
            return lowest_freed;
        }
        self.index.fetch_add(1, Ordering::SeqCst)
    }