Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
E

ecow

> 编程语言
Open source

Compact, clone-on-write vector and string.

316 stars0 likes0 views
WebsiteGitHub

About

Compact, clone-on-write vector and string.

ecow

Compact, clone-on-write vector, string, and byte buffer.

Types

  • EcoVec is a reference-counted clone-on-write vector. It takes up two words of space (= 2 usize) and has the same memory layout as a &[T] slice. Within its allocation, it stores a reference count, its capacity and its elements.

  • EcoString is a reference-counted clone-on-write string with inline storage. It takes up 16 bytes of space. It has 15 bytes of inline storage and starting from 16 bytes it becomes an EcoVec.

  • EcoBytes is a reference-counted clone-on-write byte buffer with inline storage. Like an EcoString, it takes up 16 bytes and stores up to 15 bytes inline before spilling to an EcoVec.

Example

rust
// This is stored inline.
let small = ecow::EcoString::from("Welcome");

// This spills to the heap, but only once: `big` and `third` share the
// same underlying allocation. Vectors and spilled strings are only
// really cloned upon mutation.
let big = small + " to earth! ";
let mut third = big.clone();

// This allocates again to mutate `third` without affecting `big`.
assert_eq!(third.pop(), Some(''));
assert_eq!(third, "Welcome to earth! ");

Why should I use this instead of ...

Type Details
Vec / 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.
Arc> / Arc These require two allocations instead of one and are less convenient to mutate.
Arc / Arc While these require only one allocation, they aren't mutable.
Small vector Different trade-off. Great when there are few, small Ts, but expensive to clone when spilled to the heap.
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.

License

This crate is dual-licensed under the MIT and Apache 2.0 licenses.

Issues· 5 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言