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: skinning.rs
    path of file: ./repos/amethyst/amethyst_rendy/src/submodules
    
    the code of the file until where you have to start completion: //! 3D Skinned per-image buffer handling.
use amethyst_core::ecs::Entity;
use fnv::FnvHashMap;
use rendy::resource::SubRange;
#[cfg(feature = "profiler")]
use thread_profiler::profile_scop
    
    fn commit(&mut self, factory: &Factory<B>, data: &[u8]) {
        if data.is_empty() {
            return;
        }

        let allocated = util::ensure_buffer(
            factory,
            &mut self.buffer,
            hal::buffer::Usage::STORAGE,
            rendy::memory::Dynamic,
            data.len() as u64,
        )
        .unwrap();

        if let Some(buffer) = self.buffer.as_mut() {
            if allocated {
                unsafe {
                    factory.write_descriptor_sets(Some(util::desc_write(
                        self.set.raw(),
                        0,
                        Descriptor::Buffer(buffer.raw(), SubRange::WHOLE),
                    )));
                }
            }

            let mut mapped = buffer.map(factory.device(), 0..data.len() as u64).unwrap();
            let mut writer = unsafe {
                mapped
                    .write(factory.device(), 0..data.len() as u64)
                    .unwrap()
            };
            let dst_slice = unsafe { writer.slice() };
            dst_slice.copy_from_slice(data);
        }
    }