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.

Returns true if this RopeSliceMut is empty.

Examples

A RopeSliceMut into an empty rope should be empty:

use an_rope::Rope;
let mut an_empty_rope = Rope::new();
assert!(an_empty_rope.slice_mut(0..0).is_empty());

A RopeSliceMut that contains no characters should be empty, even fi the sliced Rope is not empty:

use an_rope::Rope;
let mut an_rope = Rope::from("a string that is not empty");
assert!(an_rope.slice_mut(0..0).is_empty());

A RopeSliceMut with characters should not be empty:

use an_rope::Rope;
let mut an_rope = Rope::from("a string");
assert!(!an_rope.slice_mut(0..5).is_empty());

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

If built with --features unstable: ```

![feature(collections)]

![feature(collections_range)]

[cfg(feature = "unstable")]

extern crate collections; extern crate an_rope;

[cfg(feature = "unstable")]

fn main() {

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

If built with --features unstable: ```

![feature(collections)]

![feature(collections_range)]

[cfg(feature = "unstable")]

extern crate collections; extern crate an_rope;

[cfg(feature = "unstable")]

fn main() {

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

If built with --features unstable: ```

![feature(collections)]

![feature(collections_range)]

[cfg(feature = "unstable")]

extern crate collections; extern crate an_rope;

[cfg(feature = "unstable")]

fn main() {

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