{"id":22594889,"url":"https://github.com/avi-d-coder/ropey-iterator","last_synced_at":"2025-08-05T16:05:50.580Z","repository":{"id":54377290,"uuid":"175167342","full_name":"Avi-D-coder/ropey-iterator","owner":"Avi-D-coder","description":"A fork of the ropey UTF-8 ropes library with DoubleEndedIterator over lines","archived":false,"fork":false,"pushed_at":"2021-02-22T11:14:10.000Z","size":1044,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-02T19:51:24.365Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Avi-D-coder.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-12T08:30:30.000Z","updated_at":"2019-06-17T04:29:45.000Z","dependencies_parsed_at":"2022-08-13T13:50:34.398Z","dependency_job_id":null,"html_url":"https://github.com/Avi-D-coder/ropey-iterator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avi-D-coder%2Fropey-iterator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avi-D-coder%2Fropey-iterator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avi-D-coder%2Fropey-iterator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avi-D-coder%2Fropey-iterator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Avi-D-coder","download_url":"https://codeload.github.com/Avi-D-coder/ropey-iterator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246085636,"owners_count":20721212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-08T10:07:55.978Z","updated_at":"2025-03-28T19:13:38.768Z","avatar_url":"https://github.com/Avi-D-coder.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Forked from https://github.com/cessen/ropey\n\n## Fork Features\n- #### Lines\n    - `DoubleEndedIterator` over `Lines`\n    - `ExactSizeIterator` and `size_hint()` for `Lines`\n    - Ergonomic linewise Indexing with `narrow()`\n    - `Eq` for `Lines`\n    - `Debug` for `Lines`\n    - Optimized `nth()` on `Lines`\n    - **Breaking Change:** an empty line is not added after a trailing/terminating line-break. The new behavior is more consistent with the lines `Iterators` in `std`. \n    - Add `line-break-count` argument to `Lines::from_str`.\n    - Impl `Lines` `From` `\u0026str`. \n- #### General\n    - `Hash` for `Rope` and `RopeSlice`\n\n# Ropey\n\nRopey is a utf8 text rope for Rust, designed to be the backing text-buffer for\napplications such as text editors.  Ropey is fast, robust, and can handle huge\ntexts and memory-incoherent edits with ease.\n\n\n## Example Usage\n\n```rust\n// Load a text file.\nlet mut text = ropey::Rope::from_reader(\n    File::open(\"my_great_book.txt\")?\n)?;\n\n// Print the 516th line (zero-indexed).\nprintln!(\"{}\", text.line(515));\n\n// Get the start/end char indices of the line.\nlet start_idx = text.line_to_char(515);\nlet end_idx = text.line_to_char(516);\n\n// Remove the line...\ntext.remove(start_idx..end_idx);\n\n// ...and replace it with something better.\ntext.insert(start_idx, \"The flowers are... so... dunno.\\n\");\n\n// Print the changes, along with the previous few lines for context.\nlet start_idx = text.line_to_char(511);\nlet end_idx = text.line_to_char(516);\nprintln!(\"{}\", text.slice(start_idx..end_idx));\n\n// Write the file back out to disk.\ntext.write_to(\n    BufWriter::new(File::create(\"my_great_book.txt\")?)\n)?;\n```\n\n## When Should I Use Ropey?\n\nRopey is designed and built to be the backing text buffer for applications\nsuch as text editors, and its design trade-offs reflect that.  Ropey is good\nat:\n\n- Handling frequent edits to medium-to-large texts.  Even on texts that are\n  multiple gigabytes large, edits are measured in single-digit microseconds.\n- Handling Unicode correctly.  It is impossible to create invalid utf8 through\n  Ropey, and all Unicode line endings are correctly tracked including CRLF.\n- Having flat, predictable performance characteristics.  Ropey will never be\n  the source of hiccups or stutters in your software.\n\nOn the other hand, Ropey is _not_ good at:\n\n- Handling texts smaller than a couple of kilobytes or so.  That is to say,\n  Ropey will handle them fine, but Ropey allocates space in kilobyte chunks,\n  which introduces unnecessary bloat if your texts are almost always small.\n- Handling texts that are larger than available memory.  Ropey is an in-memory\n  data structure.\n- Getting the best performance for every possible use-case.  Ropey puts work\n  into tracking both line endings and unicode scalar values, which is\n  performance overhead you may not need depending on your use-case.\n\nKeep this in mind when selecting Ropey for your project.  Ropey is very good\nat what it does, but like all software it is designed with certain\napplications in mind.\n\n\n## Features\n\n### Strong Unicode support\nRopey's atomic unit of text is\n[Unicode scalar values](https://www.unicode.org/glossary/#unicode_scalar_value)\n(or [`char`](https://doc.rust-lang.org/std/primitive.char.html)s in Rust)\nencoded as utf8.  All of Ropey's editing and slicing operations are done\nin terms of char indices, which prevents accidental creation of invalid\nutf8 data.\n\n### Line-aware\n\nRopey knows about line breaks, allowing you to index into and iterate over\nlines of text.\n\nRopey also recognizes all eight Unicode-specified line breaks:\nline feed, carriage return, carriage return + line feed, vertical tab,\nform feed, next line, line separator, and paragraph separator.\n\n### Rope slices\n\nRopey has rope slices that allow you to work with just parts of a rope, using\nall the read-only operations of a full rope including iterators and making\nsub-slices.\n\n### Flexible APIs with low-level access\n\nAlthough Ropey is intentionally limited in scope, it also provides APIs for\nefficiently accessing and working with its internal text chunk\nrepresentation, allowing additional functionality to be efficiently\nimplemented by client code with minimal overhead.\n\n### Efficient\n\nRopey is fast and minimizes memory usage:\n\n- On a recent mobile i7 Intel CPU, Ropey performed over 1.8 million small\n  incoherent insertions per second while building up a text roughly 100 MB\n  large.  Coherent insertions (i.e. all near the same place in the text) are\n  even faster, doing the same task at over 3.3 million insertions per\n  second.\n- Freshly loading a file from disk only incurs about 10% memory overhead.  For\n  example, a 100 MB text file will occupy about 110 MB of memory when loaded\n  by Ropey.\n- Cloning ropes is _extremely_ cheap.  Rope clones share data, so an initial\n  clone only takes 8 bytes of memory.  After that, memory usage will grow\n  incrementally as the clones diverge due to edits.\n\n### Thread safe\n\nRopey ensures that even though clones share memory, everything is thread-safe.\nClones can be sent to other threads for both reading and writing.\n\n\n## Unsafe code\n\nRopey uses unsafe code to help achieve some of its space and performance\ncharacteristics.  Although effort has been put into keeping the unsafe code\ncompartmentalized and making it correct, please be cautious about using Ropey\nin software that may face adversarial conditions.\n\nAuditing, fuzzing, etc. of the unsafe code in Ropey is extremely welcome.\nIf you find any unsoundness, _please_ file an issue!  Also welcome are\nrecommendations for how to remove any of the unsafe code without introducing\nsignificant space or performance regressions, or how to compartmentalize the\nunsafe code even better.\n\n\n## License\n\nRopey is licensed under the MIT license (LICENSE.md or http://opensource.org/licenses/MIT)\n\n\n## Contributing\n\nContributions are absolutely welcome!  However, please open an issue or email\nme to discuss larger changes, to avoid doing a lot of work that may get\nrejected.\n\nAn overview of Ropey's design can be found [here](https://github.com/cessen/ropey/blob/master/design/design.md).\n\nUnless you explicitly state otherwise, any contribution intentionally\nsubmitted for inclusion in Ropey by you will be licensed as above, without any additional terms or conditions.\n\n[crates-io-badge]: https://img.shields.io/crates/v/ropey.svg\n[crates-io-url]: https://crates.io/crates/ropey\n[trav-ci-img]: https://travis-ci.org/cessen/ropey.svg?branch=master\n[trav-ci]: https://travis-ci.org/cessen/ropey\n[docs-rs-img]: https://docs.rs/ropey/badge.svg\n[docs-rs-url]: https://docs.rs/ropey\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favi-d-coder%2Fropey-iterator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favi-d-coder%2Fropey-iterator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favi-d-coder%2Fropey-iterator/lists"}