pub struct CircularBuffer<T>(Vec<T>);

#[derive(Debug, PartialEq)]
pub enum Error {
    EmptyBuffer,
    FullBuffer
}

impl<T> CircularBuffer<T> {
    pub fn new(capacity: usize) -> Self {
        CircularBuffer(Vec::with_capacity(capacity))
    }

    pub fn write(&mut self, item: T) -> Result<(), Error> {
        if self.0.len() == self.0.capacity() {
            return Err(Error::FullBuffer)
        }

        Ok(self.0.push(item))
    }

    pub fn overwrite(&mut self, item: T) {
        if self.0.len() == self.0.capacity() {
            self.0.remove(0);
        }

        self.0.push(item);
    }

    pub fn read(&mut self) -> Result<T, Error> {
        if self.0.len() == 0 {
            return Err(Error::EmptyBuffer)
        }

        Ok(self.0.remove(0))
    }

    pub fn clear(&mut self) {
        self.0.clear();
    }
}

pub struct CircularBuffer<T> {
    buffer: Vec<T>,
    capacity: usize
}

#[derive(Debug, PartialEq)]
pub enum Error {
    EmptyBuffer,
    FullBuffer
}

impl<T> CircularBuffer<T> {
    pub fn new(capacity: usize) -> Self {
        CircularBuffer {
            buffer: Vec::with_capacity(capacity),
            capacity: capacity
        }
    }

    pub fn write(&mut self, item: T) -> Result<(), Error> {
        if self.buffer.len() == self.capacity {
            return Err(Error::FullBuffer)
        }

        Ok(self.buffer.push(item))
    }

    pub fn overwrite(&mut self, item: T) {
        if self.buffer.len() == self.capacity {
            self.buffer.remove(0);
        }

        self.buffer.push(item);
    }

    pub fn read(&mut self) -> Result<T, Error> {
        if self.buffer.len() == 0 {
            return Err(Error::EmptyBuffer)
        }

        Ok(self.buffer.remove(0))
    }

    pub fn clear(&mut self) {
        self.buffer.clear();
    }
}

--- 
+++ 
@@ -1,7 +1,4 @@
-pub struct CircularBuffer<T> {
-    buffer: Vec<T>,
-    capacity: usize
-}
+pub struct CircularBuffer<T>(Vec<T>);
 
 #[derive(Debug, PartialEq)]
 pub enum Error {
@@ -11,37 +8,34 @@
 
 impl<T> CircularBuffer<T> {
     pub fn new(capacity: usize) -> Self {
-        CircularBuffer {
-            buffer: Vec::with_capacity(capacity),
-            capacity: capacity
-        }
+        CircularBuffer(Vec::with_capacity(capacity))
     }
 
     pub fn write(&mut self, item: T) -> Result<(), Error> {
-        if self.buffer.len() == self.capacity {
+        if self.0.len() == self.0.capacity() {
             return Err(Error::FullBuffer)
         }
 
-        Ok(self.buffer.push(item))
+        Ok(self.0.push(item))
     }
 
     pub fn overwrite(&mut self, item: T) {
-        if self.buffer.len() == self.capacity {
-            self.buffer.remove(0);
+        if self.0.len() == self.0.capacity() {
+            self.0.remove(0);
         }
 
-        self.buffer.push(item);
+        self.0.push(item);
     }
 
     pub fn read(&mut self) -> Result<T, Error> {
-        if self.buffer.len() == 0 {
+        if self.0.len() == 0 {
             return Err(Error::EmptyBuffer)
         }
 
-        Ok(self.buffer.remove(0))
+        Ok(self.0.remove(0))
     }
 
     pub fn clear(&mut self) {
-        self.buffer.clear();
+        self.0.clear();
     }
 }
Simplify solution for Circular Buffer
