Struct an_rope::RopeSliceMut [] [src]

pub struct RopeSliceMut<'a> { /* fields omitted */ }

An mutable borrowed slice of a Rope.

A RopeSliceMut represents a mutable borrowed slice of some or all the characters in a Rope.

Methods

impl<'a> RopeSliceMut<'a>
[src]

Returns the length of self.

This length is in bytes, not chars or graphemes. In other words, it may not be what a human considers the length of the string.

Insert rope into index in this mutable RopeSlice.

Note that the index to insert into is relative to the beginning of this slice, not to the beginning of the sliced Rope.

Consumes rope.

Panics

  • If index is greater than the length of this RopeSlice

Time Complexity

O(log n)

Examples

#![feature(collections)]
#![feature(collections_range)]

extern crate collections;
extern crate an_rope;

use collections::range::RangeArgument;
use an_rope::Rope;

let mut rope = Rope::from("this is a string");
{ // we have to create a new block here so that the mutable borrow
  // on `Rope` will end
   let mut slice = rope.slice_mut(8..);
   slice.insert_rope(1, Rope::from("n example"));
}
assert_eq!(&rope, "this is an example string");

Insert ch into index in this mutable RopeSlice.

Note that the index to insert into is relative to the beginning of this slice, not to the beginning of the sliced Rope.

Consumes ch.

Panics

  • If index is greater than the length of this RopeSlice

Time Complexity

O(log n)

Examples

#![feature(collections)]
#![feature(collections_range)]

extern crate collections;
extern crate an_rope;

use collections::range::RangeArgument;
use an_rope::Rope;

let mut rope = Rope::from("this is a string");
{ // we have to create a new block here so that the mutable borrow
  // on `Rope` will end
   let mut slice = rope.slice_mut(8..);
   slice.insert(1, 'n');
}
assert_eq!(&rope, "this is an string");

Insert s into index in this mutable RopeSlice.

Note that the index to insert into is relative to the beginning of this slice, not to the beginning of the sliced Rope.

Panics

  • If index is greater than the length of this RopeSlice

Time Complexity

O(log n)

Examples

#![feature(collections)]
#![feature(collections_range)]

extern crate collections;
extern crate an_rope;

use collections::range::RangeArgument;
use an_rope::Rope;

let mut rope = Rope::from("this is a string");
{ // we have to create a new block here so that the mutable borrow
  // on `Rope` will end
   let mut slice = rope.slice_mut(8..);
   slice.insert_str(1, "n example");
}
assert_eq!(&rope, "this is an example string");

Trait Implementations

impl<'a> Debug for RopeSliceMut<'a>
[src]

Formats the value using the given formatter.

impl<'a> Eq for RopeSliceMut<'a>
[src]

impl<'a> PartialEq for RopeSliceMut<'a>
[src]

A rope equals another rope if all the bytes in both are equal.

This method tests for !=.

impl<'a, 'b> PartialEq<RopeSlice<'b>> for RopeSliceMut<'a>
[src]

A rope equals another rope if all the bytes in both are equal.

This method tests for !=.

impl<'a> PartialEq<str> for RopeSliceMut<'a>
[src]

A rope equals another rope if all the bytes in both are equal.

This method tests for !=.

impl<'a> Into<Rope> for RopeSliceMut<'a>
[src]

Converts this RopeSliceMut into a new Rope

impl<'a> Into<String> for RopeSliceMut<'a>
[src]

Converts this RopeSliceMut into a new String