Struct rope::Rope 
            [-]
             [+]
        [src]
pub struct Rope {
    // some fields omitted
}A Rope is a tree of Strings that allows more efficient storage and
manipulation of large amounts of text than a String.
Methods
impl Rope
fn new() -> Rope
Creates a new, empty Rope.
fn from_string(string: String) -> Rope
Creates a new Rope from the given String.
fn append(&mut self, rope: Rope)
Append rope to the end of the Rope.
fn append_string(&mut self, string: String)
Appends string to the end of the Rope.
Example
let mut rope = Rope::from_string("ab".to_string()); rope.append_string("cd".to_string()); assert!(rope.equiv(&"abcd"));
fn prepend(&mut self, rope: Rope)
Prepends rope to the beginning of the Rope.
fn prepend_string(&mut self, string: String)
Prepends string to the beginning of the Rope.
Example
let mut rope = Rope::from_string("ab".to_string()); rope.prepend_string("cd".to_string()); assert!(rope.equiv(&"cdab"));
fn split(self, index: uint) -> (Rope, Rope)
Splits the Rope into two Ropes at the given index.
Returns the pair of Ropes to the left and right of the split.
Failure
If index is greater than the length of the Rope.
If index is not a valid character boundary.
Example
let rope = Rope::from_string("abcd".to_string()); let (left, right) = rope.split(2); assert!(left.equiv(&"ab")); assert!(right.equiv(&"cd"));
fn insert(&mut self, index: uint, rope: Rope)
Inserts rope at index into the Rope.
Failure
If index is greater than the length of the Rope.
If index is not a valid character boundary.
fn insert_string(&mut self, index: uint, string: String)
Inserts string at index into the Rope.
Failure
If index is greater than the length of the Rope.
If index is not a valid character boundary.
Example
let mut rope = Rope::from_string("ab".to_string()); rope.insert_string(1, "cd".to_string()); assert!(rope.equiv(&"acdb"));
fn delete(&mut self, start: uint, end: uint) -> Rope
Deletes the substring of the Rope from start to end.
Returns a Rope of the deleted substring.
Failure
If start > end.
If start or end is greater than the length of the Rope.
If start or end is not a valid character boundary.
Example
let mut rope = Rope::from_string("abcd".to_string()); rope.delete(1, 3); assert!(rope.equiv(&"ad"));
fn truncate(&mut self, start: uint, end: uint) -> (Rope, Rope)
Truncates the Rope to only the substring from start to end.
Returns the pair of Ropes removed from the beginning and end
of the Rope.
Failure
If start > end.
If start or end is greater than the length of the Rope.
If start or end is not a valid character boundary.
Example
let mut rope = Rope::from_string("abcd".to_string()); rope.truncate(1, 3); assert!(rope.equiv(&"bc"));
fn substring<'r>(&'r self, start: uint, end: uint) -> MaybeOwned<'r>
Returns the substring of the Rope from start to end.
Failure
If start > end.
If start or end is greater than the length of the Rope.
If start or end is not a valid character boundary.
Example
let rope = Rope::from_string("abcd".to_string()); assert!(rope.substring(0, 2).equiv(&"ab")); assert!(rope.substring(2, 4).equiv(&"cd"));
fn strings<'r>(&'r self) -> RopeStrings<'r>
Returns an iterator over the strings of the Rope.
fn chars<'r>(&'r self) -> RopeChars<'r>
Returns an iterator over the chars of the Rope.
fn bytes<'r>(&'r self) -> RopeBytes<'r>
Returns an iterator over the bytes of the Rope.