use std::slice::Iter;
use std::sync::Arc;
#[derive(Debug)]
pub(crate) struct StatelessTracker<T> {
resources: Vec<Arc<T>>,
}
impl<T> StatelessTracker<T> {
pub fn new() -> Self {
Self {
resources: Vec::new(),
}
}
pub fn insert_single(&mut self, resource: Arc<T>) -> &Arc<T> {
self.resources.push(resource);
unsafe { self.resources.last().unwrap_unchecked() }
}
}
impl<'a, T> IntoIterator for &'a StatelessTracker<T> {
type Item = &'a Arc<T>;
type IntoIter = Iter<'a, Arc<T>>;
fn into_iter(self) -> Self::IntoIter {
self.resources.as_slice().iter()
}
}