mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-16 01:08:05 +02:00
Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30443>
28 lines
570 B
Rust
28 lines
570 B
Rust
// 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>;
|
|
}
|