Excerpt ``` pub struct FastSliceBuffer { pub data : [T; LEN], pub end : usize, pub length : usize, } impl FastSliceBuffer { ... #[inline(always)] pub fn capacity_remaining(&self) -> usize { Self::LEN - self.length } //Add to the end of the buffer //Copy N bytes in from source pub fn add_slice(&mut self, source : &[u8]) { let remaining = self.capacity_remaining(); let num_elements_to_add = source.len().min(remaining); if num_elements_to_add==0 { return; } //We will use exclusive ranges let begin_index = self.end; self.end += num_elements_to_add; self.length += num_elements_to_add; //Copy as a single segment if self.end <= Self::LEN { self.data[begin_index..self.end].copy_from_slice(&source[0..num_elements_to_add]); } //Copy in a two segments else { let seg_length1 = Self::LEN - begin_index; self.data[begin_index..=Self::INDEX_MAX].copy_from_slice(&source[0..seg_length1]); let seg_length2 = num_elements_to_add - seg_length1; self.data[0..seg_length2].copy_from_slice(&source[seg_length1..seg_length1+seg_length2]); } if self.end >= Self::INDEX_MAX { self.end -= Self::LEN; } } ```