michis_collection_cursor 0.1.3

A cursor which wraps an indexable collection, providing a movable position which points to an index of the collection. Useful for things like history, undo-redo systems, or timelines.
Documentation
use generic_array::{ArrayLength, GenericArray};

use crate::{IndexableCollection, IndexableCollectionMut};

impl<T, N: ArrayLength> IndexableCollection for GenericArray<T, N> {
	type Item = T;

	forward_indexable!(get_item);

	fn len(&self) -> usize {
		N::USIZE
	}
}

impl<T, N: ArrayLength> IndexableCollectionMut for GenericArray<T, N> {
	forward_mutable!();
}

#[cfg(test)]
mod tests {
	use super::*;

	#[test]
	fn generic_array_len() {
		let arr = GenericArray::from_array([(); 17]);
		assert_eq!(IndexableCollection::len(&arr), 17);

		let arr = GenericArray::from_array([(); 32]);
		assert_eq!(IndexableCollection::len(&arr), 32);
	}
}