Enum persistent_rope::Rope [] [src]

pub enum Rope {
    Node(usize, Arc<Rope>, Arc<Rope>),
    Leaf(Arc<String>),
}

Variants

Methods

impl Rope
[src]

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::new();
assert_eq!(&rope, "");

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello, world!");
assert_eq!(rope.len(), 13);

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello, world!");
assert_eq!(rope.bytes_len(), 13);

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("長さ");
assert_eq!(rope.chars_len(), 2);

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello, world!");
assert!(!rope.is_empty());

[src]

Examples

use persistent_rope::Rope;
let a = Rope::from("Hello");
let b = a.insert_at_byte(5, ", world!");
assert_eq!(b.height(), 2);

[src]

Examples

use persistent_rope::Rope;
let a = Rope::from("Hello,\n");
let b = a.insert_at_byte(5, "world!\n");
assert_eq!(b.count_lines(), 2);

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Helloworld!");
assert_eq!(&rope.insert_at_byte(5, ", "), "Hello, world!");

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("長さ");
assert_eq!(&rope.insert(1, ", "), "長, さ");

[src]

Examples

use persistent_rope::Rope;
let a = Rope::from("Hello").concat(" world");
let b = a.insert_char_at_byte(5, ',');
let c = b.insert_char_at_byte(12, '!');
assert_eq!(&b, "Hello, world");
assert_eq!(&c, "Hello, world!");

[src]

Examples

use persistent_rope::Rope;
let a = Rope::from("長").concat("さ");
let b = a.insert_char(1, ',');
let c = b.insert_char(3, '!');
assert_eq!(&b, "長,さ");
assert_eq!(&c, "長,さ!");

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello, world!");
assert_eq!(&rope.remove_byte_range(5..13), "Hello");

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("長 さ");
assert_eq!(&rope.remove_range(1..2), "長さ");

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello, world!");
assert_eq!(&rope.remove_at_byte(12), "Hello, world");
assert_eq!(&rope.remove_at_byte(5), "Hello world!");

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("長さ");
assert_eq!(&rope.remove(0), "さ");
assert_eq!(&rope.remove(1), "長");

[src]

Examples

use persistent_rope::Rope;

let rope = Rope::from("Hello, world!");
let (left, right) = rope.split_at_byte(7);
assert_eq!(&left, "Hello, ");
assert_eq!(&right, "world!");

let rope = Rope::new();
let (left, right) = rope.split_at_byte(0);
assert_eq!(&left, "");
assert_eq!(&right, "");

[src]

Examples

use persistent_rope::Rope;

let rope = Rope::from("長さ");
let (left, right) = rope.split(1);
assert_eq!(&left, "長");
assert_eq!(&right, "さ");

[src]

Examples

use persistent_rope::Rope;
let left = Rope::from("Hello, ");
let right = Rope::from("world!");
assert_eq!(&left.concat(right), "Hello, world!");

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello").concat(", world");
println!("{:?}", rope);
assert_eq!(&rope.concat_char('!'), "Hello, world!");

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("長").concat(", さ!");
assert_eq!(rope.char_at(0), Some('長'));
assert_eq!(rope.char_at(1), Some(','));
assert_eq!(rope.char_at(2), Some(' '));
assert_eq!(rope.char_at(3), Some('さ'));
assert_eq!(rope.char_at(4), Some('!'));

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello").concat(", world!");
assert_eq!(rope.chunks().collect::<Vec<&String>>(), ["Hello", ", world!"].to_vec());

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello");
assert_eq!(rope.bytes().collect::<Vec<u8>>(), [72, 101, 108, 108, 111].to_vec());

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello");
assert_eq!(rope.chars().collect::<Vec<char>>(), ['H', 'e', 'l', 'l', 'o'].to_vec());

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello\n world!");
let lines = rope.lines().collect::<Vec<String>>();
assert_eq!(lines.get(0), Some(&String::from("Hello")));
assert_eq!(lines.get(1), Some(&String::from(" world!")));

[src]

Trait Implementations

impl Clone for Rope
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq for Rope
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for Rope
[src]

impl PartialOrd for Rope
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

[src]

This method tests less than (for self and other) and is used by the < operator. Read more

[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for Rope
[src]

[src]

This method returns an Ordering between self and other. Read more

1.22.0
[src]

Compares and returns the maximum of two values. Read more

1.22.0
[src]

Compares and returns the minimum of two values. Read more

impl Hash for Rope
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Sync for Rope
[src]

impl Send for Rope
[src]

impl From<Arc<Rope>> for Rope
[src]

[src]

Performs the conversion.

impl<'a> From<&'a Arc<Rope>> for Rope
[src]

[src]

Performs the conversion.

impl<'a> From<&'a Rope> for Rope
[src]

[src]

Performs the conversion.

impl<'a> From<&'a str> for Rope
[src]

[src]

Performs the conversion.

impl<'a> From<&'a String> for Rope
[src]

[src]

Performs the conversion.

impl From<String> for Rope
[src]

[src]

Performs the conversion.

impl Into<String> for Rope
[src]

[src]

Performs the conversion.

impl<'a> IntoIterator for &'a Rope
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

impl<T> Add<T> for Rope where
    T: Into<Rope>, 
[src]

The resulting type after applying the + operator.

[src]

Examples

use persistent_rope::Rope;
let a = Rope::from("Hello");
let b = Rope::from(", world!");
assert_eq!(a.clone() + b, "Hello, world!");
assert_eq!(a + ", world!", "Hello, world!");

impl<'a, T> Add<T> for &'a Rope where
    T: Into<Rope>, 
[src]

The resulting type after applying the + operator.

[src]

Examples

use persistent_rope::Rope;
let a = Rope::from("Hello");
let b = Rope::from(", world!");
assert_eq!(&a + &b, "Hello, world!");
assert_eq!(&a + b.clone(), "Hello, world!");
assert_eq!(a.clone() + &b, "Hello, world!");

impl Add<char> for Rope
[src]

The resulting type after applying the + operator.

[src]

Examples

use persistent_rope::Rope;
let a = Rope::from("Hello");
assert_eq!(a + '!', "Hello!");

impl<'a> Add<char> for &'a Rope
[src]

The resulting type after applying the + operator.

[src]

Examples

use persistent_rope::Rope;
let a = Rope::from("Hello");
assert_eq!(&a + '!', "Hello!");

impl ToString for Rope
[src]

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello, world!");
assert_eq!(rope.to_string(), "Hello, world!");

impl Debug for Rope
[src]

[src]

Formats the value using the given formatter.

impl<'a> PartialEq<&'a str> for Rope
[src]

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello, world!");
assert_eq!(&rope, "Hello, world!");
assert_ne!(&rope, "Hello!");

1.0.0
[src]

This method tests for !=.

impl PartialEq<str> for Rope
[src]

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello, world!");
assert_eq!(rope, "Hello, world!");
assert_ne!(rope, "Hello!");

1.0.0
[src]

This method tests for !=.

impl PartialEq<String> for Rope
[src]

[src]

Examples

use persistent_rope::Rope;
let rope = Rope::from("Hello, world!");
assert_eq!(&rope, &String::from("Hello, world!"));
assert_ne!(&rope, &String::from("Hello!"));

1.0.0
[src]

This method tests for !=.