{"id":13599852,"url":"https://github.com/typst/ecow","last_synced_at":"2025-05-16T10:06:27.830Z","repository":{"id":70517882,"uuid":"604327061","full_name":"typst/ecow","owner":"typst","description":"Compact, clone-on-write vector and string.","archived":false,"fork":false,"pushed_at":"2025-04-24T11:52:37.000Z","size":99,"stargazers_count":255,"open_issues_count":3,"forks_count":20,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-24T12:49:21.119Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/typst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["typst"]}},"created_at":"2023-02-20T20:30:29.000Z","updated_at":"2025-04-24T11:52:11.000Z","dependencies_parsed_at":"2024-06-09T16:20:30.971Z","dependency_job_id":"6d4115a2-7b2e-48f2-9bec-32326311d46c","html_url":"https://github.com/typst/ecow","commit_stats":{"total_commits":44,"total_committers":4,"mean_commits":11.0,"dds":"0.40909090909090906","last_synced_commit":"c3fd0360b1684926396f59d4b18d01f6a594869f"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typst%2Fecow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typst%2Fecow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typst%2Fecow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typst%2Fecow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typst","download_url":"https://codeload.github.com/typst/ecow/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509475,"owners_count":22082891,"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-08-01T17:01:13.818Z","updated_at":"2025-05-16T10:06:27.808Z","avatar_url":"https://github.com/typst.png","language":"Rust","funding_links":["https://github.com/sponsors/typst"],"categories":["Rust"],"sub_categories":[],"readme":"# ecow\n[![Crates.io](https://img.shields.io/crates/v/ecow.svg)](https://crates.io/crates/ecow)\n[![Documentation](https://docs.rs/ecow/badge.svg)](https://docs.rs/ecow)\n\nCompact, clone-on-write vector and string.\n\n## Types\n- An `EcoVec` is a reference-counted clone-on-write vector. It takes up two\n  words of space (= 2 usize) and has the same memory layout as a `\u0026[T]` slice.\n  Within its allocation, it stores a reference count, its capacity and its\n  elements.\n\n- An `EcoString` is a reference-counted clone-on-write string with inline\n  storage. It takes up 16 bytes of space. It has 15 bytes of inline storage and\n  starting from 16 bytes it becomes an `EcoVec\u003cu8\u003e`.\n\n## Example\n```rust\n// This is stored inline.\nlet small = ecow::EcoString::from(\"Welcome\");\n\n// This spills to the heap, but only once: `big` and `third` share the\n// same underlying allocation. Vectors and spilled strings are only\n// really cloned upon mutation.\nlet big = small + \" to earth! 🌱\";\nlet mut third = big.clone();\n\n// This allocates again to mutate `third` without affecting `big`.\nassert_eq!(third.pop(), Some('🌱'));\nassert_eq!(third, \"Welcome to earth! \");\n```\n\n## Why should I use this instead of ...\n\n| Type                                        | Details |\n|:--------------------------------------------|:--------|\n| [`Vec\u003cT\u003e`][vec] / [`String`][string]        | Normal vectors are a great general purpose data structure. But they have a quite big footprint (3 machine words) and are expensive to clone. The `EcoVec` has a bit of overhead for mutation, but is cheap to clone and only takes two words. |\n| [`Arc\u003cVec\u003cT\u003e\u003e`][arc] / [`Arc\u003cString\u003e`][arc] | These require two allocations instead of one and are less convenient to mutate. |\n| [`Arc\u003c[T]\u003e`][arc] / [`Arc\u003cstr\u003e`][arc]       | While these require only one allocation, they aren't mutable. |\n| Small vector                                | Different trade-off. Great when there are few, small `T`s, but expensive to clone when spilled to the heap. |\n| Small string                                | The `EcoString` combines different small string qualities into a very practical package: It has inline storage, a smaller footprint than a normal `String`, is efficient to clone even when spilled, and at the same time mutable. |\n\n[vec]: https://doc.rust-lang.org/std/vec/struct.Vec.html\n[string]: https://doc.rust-lang.org/std/string/struct.String.html\n[arc]: https://doc.rust-lang.org/std/sync/struct.Arc.html\n\n## License\nThis crate is dual-licensed under the MIT and Apache 2.0 licenses.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypst%2Fecow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypst%2Fecow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypst%2Fecow/lists"}