[−][src]Struct ropey::RopeBuilder
An efficient incremental Rope
builder.
This is used to efficiently build ropes from sequences of text chunks. It is useful for creating ropes from:
- ...large text files, without pre-loading their entire contents into
memory (but see
Rope::from_reader()
for a convenience function that does this for utf8 text). - ...streaming data sources.
- ...non-utf8 text data, doing the encoding conversion incrementally as you go.
Unlike repeatedly calling Rope::insert()
on the end of a rope,
this API runs in time linear to the amount of data fed to it, and
is overall much faster.
Example
let mut builder = RopeBuilder::new(); builder.append("Hello "); builder.append("world!\n"); builder.append("How's "); builder.append("it goin"); builder.append("g?"); let rope = builder.finish(); assert_eq!(rope, "Hello world!\nHow's it going?");
Implementations
impl RopeBuilder
[src]
pub fn new() -> Self
[src]
Creates a new RopeBuilder, ready for input.
pub fn append(&mut self, chunk: &str)
[src]
Appends chunk
to the end of the in-progress Rope
.
This method is called repeatedly to incrementally build up a
Rope
. The passed text chunk can be as large or small as
desired, but larger chunks are more efficient.
chunk
must be valid utf8 text.
pub fn finish(self) -> Rope
[src]
Finishes the build, and returns the Rope
.
Note: this method consumes the builder. If you want to continue
building other ropes with the same prefix, you can clone the builder
before calling finish()
.
Trait Implementations
impl Clone for RopeBuilder
[src]
fn clone(&self) -> RopeBuilder
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for RopeBuilder
[src]
impl Default for RopeBuilder
[src]
fn default() -> RopeBuilder
[src]
Auto Trait Implementations
impl RefUnwindSafe for RopeBuilder
impl Send for RopeBuilder
impl Sync for RopeBuilder
impl Unpin for RopeBuilder
impl UnwindSafe for RopeBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,