Edit

IABSD.fr/xenocara/lib/mesa/src/compiler/rust/as_slice.rs

Branch :

  • Show log

    Commit

  • Author : jsg
    Date : 2025-06-05 11:23:11
    Hash : 67d6f117
    Message : Import Mesa 25.0.7

  • lib/mesa/src/compiler/rust/as_slice.rs
  • // Copyright © 2024 Collabora, Ltd.
    // SPDX-License-Identifier: MIT
    
    use std::ops::Index;
    
    pub enum AttrList<T: 'static> {
        Array(&'static [T]),
        Uniform(T),
    }
    
    impl<T: 'static> Index<usize> for AttrList<T> {
        type Output = T;
    
        fn index(&self, idx: usize) -> &T {
            match self {
                AttrList::Array(arr) => &arr[idx],
                AttrList::Uniform(typ) => typ,
            }
        }
    }
    
    pub trait AsSlice<T> {
        type Attr;
    
        fn as_slice(&self) -> &[T];
        fn as_mut_slice(&mut self) -> &mut [T];
        fn attrs(&self) -> AttrList<Self::Attr>;
    }