https://github.com/duesee/u8rope
Simple rope data structure based on bytes (u8).
https://github.com/duesee/u8rope
Last synced: 3 months ago
JSON representation
Simple rope data structure based on bytes (u8).
- Host: GitHub
- URL: https://github.com/duesee/u8rope
- Owner: duesee
- License: agpl-3.0
- Created: 2017-01-15T15:32:43.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-17T17:23:08.000Z (almost 9 years ago)
- Last Synced: 2025-04-05T09:30:57.371Z (9 months ago)
- Language: Rust
- Size: 24.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# u8rope (unusable)
This crate may provide a persistent rope based on bytes (u8).
The aim is to explore data structure design in Rust by using `std::rc::Rc`, `std::borrow::Cow`, etc.
Design decisions are aimed towards undo/redo functionality, lazy-loading and ease-of-use.
## Example
```Rust
extern crate u8rope;
use u8rope::Rope;
fn main() {
let rope = Rope::from("Hello,... World!");
println!("{}", rope); // "Hello,... World!"
let rope = rope.delete(6, 3);
println!("{}", rope); // "Hello, World!"
let rope = rope.delete(7, 5);
println!("{}", rope); // "Hello, !"
let rope = rope.insert(7, &Rope::from("Universe"));
println!("{}", rope); // "Hello, Universe!"
let (left, right) = rope.split(6);
println!("{}", left); // "Hello,"
println!("{}", right); // " Universe!"
let rope = rope.append(&Rope::from("!!"));
println!("{}", rope); // "Hello, Universe!!!"
}
```