fn buffer_data_mut<'a>(
        buffer_views: &[gltf::BufferView],
        buffers: &'a mut [Buffer],
        buffer_view: usize,
    ) -> Result<&'a mut [u8], ModelError> {
        let view = buffer_views
            .get(buffer_view)
            .ok_or_else(|| ModelError::BadIndex {
                array: "Buffer views",
                got: buffer_view,
                max: buffer_views.len(),
            })?;

        let buffer_len = buffers.len();

        let buffer = buffers.get_mut(view.buffer).ok_or(ModelError::BadIndex {
            array: "Buffers",
            got: view.buffer,
            max: buffer_len,
        })?;

        let buffer_len = buffer.data.len();

        Ok(buffer
            .data
            .get_mut(view.byte_offset..(view.byte_offset + view.byte_length))
            .ok_or(ModelError::BadIndex {
                array: "Buffer get",
                got: view.byte_offset + view.byte_length,
                max: buffer_len,
            })?)
    }
// try to get the mutable data for a buffer view
// doesn't take self, instead takes slices so the borrows on self can be
// split to allow both mut and immutable references to parts of self
try to get the mutable data for a buffer view
doesn't take self, instead takes slices so the borrows on self can be
split to allow both mut and immutable references to parts of self
try to get the mutable data for a buffer view doesn ' t take self instead takes slices so the borrows on self can be split to allow both mut and immutable references to parts of self
fn buffer_data_mut<'a>(
        buffer_views: &[gltf::BufferView],
        buffers: &'a mut [Buffer],
        buffer_view: usize,
    ) -> Result<&'a mut [u8], ModelError> {
        let view = buffer_views
            .get(buffer_view)
            .ok_or_else(|| ModelError::BadIndex {
                array: "Buffer views",
                got: buffer_view,
                max: buffer_views.len(),
            })?;
        let buffer_len = buffers.len();
        let buffer = buffers.get_mut(view.buffer).ok_or(ModelError::BadIndex {
            array: "Buffers",
            got: view.buffer,
            max: buffer_len,
        })?;
        let buffer_len = buffer.data.len();
        Ok(buffer
            .data
            .get_mut(view.byte_offset..(view.byte_offset + view.byte_length))
            .ok_or(ModelError::BadIndex {
                array: "Buffer get",
                got: view.byte_offset + view.byte_length,
                max: buffer_len,
            })?)
    }
fn buffer_data_mut < ' a > ( buffer_views : & [ gltf :: BufferView ] , buffers : & ' a mut [ Buffer ] , buffer_view : usize , ) -> Result < & ' a mut [ u8 ] , ModelError > { let view = buffer_views . get ( buffer_view ) . ok_or_else ( | | ModelError :: BadIndex { array : " " , got : buffer_view , max : buffer_views . len ( ) , } ) ? ; let buffer_len = buffers . len ( ) ; let buffer = buffers . get_mut ( view . buffer ) . ok_or ( ModelError :: BadIndex { array : " " , got : view . buffer , max : buffer_len , } ) ? ; let buffer_len = buffer . data . len ( ) ; Ok ( buffer . data . get_mut ( view . byte_offset .. ( view . byte_offset + view . byte_length ) ) . ok_or ( ModelError :: BadIndex { array : " " , got : view . byte_offset + view . byte_length , max : buffer_len , } ) ? ) }
try to get the mutable data for a buffer view
doesn't take self, instead takes slices so the borrows on self can be
split to allow both mut and immutable references to parts of self
try to get the mutable data for a buffer view doesn ' t take self instead takes slices so the borrows on self can be split to allow both mut and immutable references to parts of self
buffer_views
&[gltf::BufferView]
buffers
&'a mut [Buffer]
buffer_view
usize
buffer_views
&[gltf::BufferView]
buffers
&'a mut [Buffer]
buffer_view
usize