fn enlarge(&mut self) -> Result<(), ()> {
		//if self.start == 0 && self.end == self.buf.len() {
		if self.len() == self.buf.len() {
			// this buffer is already full, double its size
			self.buf.reserve(self.buf.len());
			unsafe { self.buf.set_len(self.buf.len() * 2) };
		} else {
			// reallocate and fill existing buffer
			if self.end - self.start != 0 {
				//self.buf.copy_within(self.start..self.end, 0)
				copy_in_place(&mut self.buf, self.start..self.end, 0);
			}
			self.end -= self.start;
			self.start = 0;
		}
		Ok(())
	}
// make room for new data one way or the other
make room for new data one way or the other
make room for new data one way or the other
fn enlarge(&mut self) -> Result<(), ()> {
		//if self.start == 0 && self.end == self.buf.len() {
		if self.len() == self.buf.len() {
			// this buffer is already full, double its size
			self.buf.reserve(self.buf.len());
			unsafe { self.buf.set_len(self.buf.len() * 2) };
		} else {
			// reallocate and fill existing buffer
			if self.end - self.start != 0 {
				//self.buf.copy_within(self.start..self.end, 0)
				copy_in_place(&mut self.buf, self.start..self.end, 0);
			}
			self.end -= self.start;
			self.start = 0;
		}
		Ok(())
	}
fn enlarge ( & mut self ) -> Result < ( ) , ( ) > { //if self.start == 0 && self.end == self.buf.len() { if self . len ( ) == self . buf . len ( ) { // this buffer is already full, double its size self . buf . reserve ( self . buf . len ( ) ) ; unsafe { self . buf . set_len ( self . buf . len ( ) * 2 ) } ; } else { // reallocate and fill existing buffer if self . end - self . start != 0 { //self.buf.copy_within(self.start..self.end, 0) copy_in_place ( & mut self . buf , self . start .. self . end , 0 ) ; } self . end -= self . start ; self . start = 0 ; } Ok ( ( ) ) }
make room for new data one way or the other
make room for new data one way or the other
&mut self
&mut self