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]
fn new<R>(node: &'a mut Node, range: R) -> Self where R: RangeArgument<usize>
fn chars(&'a self) -> impl Iterator<Item=char> + 'a
fn bytes(&'a self) -> impl Iterator<Item=u8> + 'a
fn split_whitespace(&'a self) -> impl Iterator<Item=&'a str>
fn lines(&'a self) -> impl Iterator<Item=&'a str>
fn char_indices(&'a self) -> impl Iterator<Item=(usize, char)> + 'a
fn len(&self) -> usize
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.
fn insert_rope(&mut self, index: usize, rope: Rope)
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 thisRopeSlice
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");
fn insert(&mut self, index: usize, ch: char)
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 thisRopeSlice
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");
fn insert_str(&mut self, index: usize, s: &str)
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 thisRopeSlice
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]
impl<'a> Eq for RopeSliceMut<'a>
[src]
impl<'a> PartialEq for RopeSliceMut<'a>
[src]
fn eq(&self, other: &RopeSliceMut<'a>) -> bool
A rope equals another rope if all the bytes in both are equal.
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<'a, 'b> PartialEq<RopeSlice<'b>> for RopeSliceMut<'a>
[src]
fn eq(&self, other: &RopeSlice<'b>) -> bool
A rope equals another rope if all the bytes in both are equal.
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<'a> PartialEq<str> for RopeSliceMut<'a>
[src]
fn eq(&self, other: &str) -> bool
A rope equals another rope if all the bytes in both are equal.
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.