1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use crate::buffer::BufferAccess;
use std::sync::Arc;
pub unsafe trait VertexBuffersCollection {
fn into_vec(self) -> Vec<Arc<dyn BufferAccess>>;
}
unsafe impl VertexBuffersCollection for () {
#[inline]
fn into_vec(self) -> Vec<Arc<dyn BufferAccess>> {
vec![]
}
}
unsafe impl<T> VertexBuffersCollection for Arc<T>
where
T: BufferAccess + 'static,
{
#[inline]
fn into_vec(self) -> Vec<Arc<dyn BufferAccess>> {
vec![self as Arc<_>]
}
}
unsafe impl<T> VertexBuffersCollection for Vec<Arc<T>>
where
T: BufferAccess + 'static,
{
#[inline]
fn into_vec(self) -> Vec<Arc<dyn BufferAccess>> {
self.into_iter().map(|source| source as Arc<_>).collect()
}
}
macro_rules! impl_collection {
($first:ident $(, $others:ident)+) => (
unsafe impl<$first$(, $others)+> VertexBuffersCollection for (Arc<$first>, $(Arc<$others>),+)
where $first: BufferAccess + 'static
$(, $others: BufferAccess + 'static)*
{
#[inline]
fn into_vec(self) -> Vec<Arc<dyn BufferAccess>> {
#![allow(non_snake_case)]
let ($first, $($others,)*) = self;
let mut list = Vec::new();
list.push($first as Arc<_>);
$(
list.push($others as Arc<_>);
)+
list
}
}
impl_collection!($($others),+);
);
($i:ident) => ();
}
impl_collection!(Z, Y, X, W, V, U, T, S, R, Q, P, O, N, M, L, K, J, I, H, G, F, E, D, C, B, A);