mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-07-17 07:46:57 +02:00
26 lines
647 B
Rust
26 lines
647 B
Rust
use crate::*;
|
|
|
|
/// Collection of samples, one per slot, fixed number of slots.
|
|
///
|
|
/// History: Separated to cleanly implement [Default].
|
|
///
|
|
/// ```
|
|
/// let samples = tek::SampleKit([None, None, None, None]);
|
|
/// ```
|
|
#[derive(Debug)] pub struct SampleKit <const N: usize> (
|
|
pub [Option<Arc<RwLock<Sample>>>;N]
|
|
);
|
|
|
|
impl<const N: usize> Default for SampleKit<N> {
|
|
fn default () -> Self { Self([const { None }; N]) }
|
|
}
|
|
|
|
impl<const N: usize> SampleKit<N> {
|
|
pub fn get (&self, index: usize) -> &Option<Arc<RwLock<Sample>>> {
|
|
if index < self.0.len() {
|
|
&self.0[index]
|
|
} else {
|
|
&None
|
|
}
|
|
}
|
|
}
|