Files
avr-webee/src/webee/vector.rs

51 lines
1010 B
Rust

use avr_device::atmega2560::TC0;
use ufmt::{Formatter, uDisplay, uWrite};
pub struct SimpleVector<T> {
size: usize,
array: [T]
}
impl<T> SimpleVector<T> {
pub fn new(size: usize, array: [T]) -> Self {
Self {
size, array
}
}
pub fn push(&mut self, byte: T) {
let array : &[T];
if self.size > 0 {
array = &mut self.array[0..self.size];
array[self.size] = byte;
} else {
array = &mut [byte];
}
self.array = array;
self.size = self.size + 1;
}
}
impl<'a, T> Iterator for SimpleVector<'a, T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
todo!()
}
}
impl<'a, T> uDisplay for SimpleVector<'a, T> {
fn fmt<W>(&self, _: &mut Formatter<'_, W>) -> Result<(), W::Error> where W: uWrite + ?Sized {
todo!()
}
}
#[macro_export]
macro_rules! vector {
($array:expr) => {
Vector::new(&mut $array.len(), $array)
};
}