use super::Position;
use super::Range;

pub struct GapBuffer {
    data: Vec<u8>,
}

pub fn new(mut data: String) -> GapBuffer {
    // Ensure that the data has enough room to grow without reallocating.
    let data_length = data.len();
    data.reserve(data_length * 2);

    GapBuffer{ data: data.into_bytes() }
}

impl GapBuffer {
    pub fn to_string(&self) -> String {
        String::from_utf8(self.data.clone()).unwrap()
    }
}

use super::Position;
use super::Range;

pub struct GapBuffer {
    data: String,
}

pub fn new(mut data: String) -> GapBuffer {
    // Ensure that the data has enough room to grow without reallocating.
    let data_length = data.len();
    data.reserve(data_length * 2);

    GapBuffer{ data: data }
}

impl GapBuffer {
    pub fn to_string(&self) -> String {
        self.data.clone()
    }
}

--- 
+++ 
@@ -2,7 +2,7 @@
 use super::Range;
 
 pub struct GapBuffer {
-    data: String,
+    data: Vec<u8>,
 }
 
 pub fn new(mut data: String) -> GapBuffer {
@@ -10,11 +10,11 @@
     let data_length = data.len();
     data.reserve(data_length * 2);
 
-    GapBuffer{ data: data }
+    GapBuffer{ data: data.into_bytes() }
 }
 
 impl GapBuffer {
     pub fn to_string(&self) -> String {
-        self.data.clone()
+        String::from_utf8(self.data.clone()).unwrap()
     }
 }
Store GapBuffer data as a byte vector.
