Skip to content

Commit 79cf7db

Browse files
flyingmutantlaurmaedje
authored andcommitted
Expose EcoBytes
1 parent e89363e commit 79cf7db

6 files changed

Lines changed: 816 additions & 60 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ version = "0.3.0"
44
rust-version = "1.73" # also change in ci.yml
55
authors = ["Laurenz <laurmaedje@gmail.com>"]
66
edition = "2021"
7-
description = "Compact, clone-on-write vector and string."
7+
description = "Compact, clone-on-write vector, string, and byte buffer."
88
repository = "https://github.com/typst/ecow"
99
readme = "README.md"
1010
license = "MIT OR Apache-2.0"
1111
categories = ["data-structures", "no-std"]
12-
keywords = ["string", "vector", "sso", "cow"]
12+
keywords = ["string", "vector", "bytes", "sso", "cow"]
1313

1414
[features]
1515
default = ["std"]

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
[![Crates.io](https://img.shields.io/crates/v/ecow.svg)](https://crates.io/crates/ecow)
33
[![Documentation](https://docs.rs/ecow/badge.svg)](https://docs.rs/ecow)
44

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

77
## Types
8-
- An `EcoVec` is a reference-counted clone-on-write vector. It takes up two
9-
words of space (= 2 usize) and has the same memory layout as a `&[T]` slice.
10-
Within its allocation, it stores a reference count, its capacity and its
11-
elements.
12-
13-
- An `EcoString` is a reference-counted clone-on-write string with inline
14-
storage. It takes up 16 bytes of space. It has 15 bytes of inline storage and
15-
starting from 16 bytes it becomes an `EcoVec<u8>`.
8+
- `EcoVec` is a reference-counted clone-on-write vector. It takes up two words
9+
of space (= 2 usize) and has the same memory layout as a `&[T]` slice. Within
10+
its allocation, it stores a reference count, its capacity and its elements.
11+
12+
- `EcoString` is a reference-counted clone-on-write string with inline storage.
13+
It takes up 16 bytes of space. It has 15 bytes of inline storage and starting
14+
from 16 bytes it becomes an `EcoVec<u8>`.
15+
16+
- `EcoBytes` is a reference-counted clone-on-write byte buffer with inline
17+
storage. Like an `EcoString`, it takes up 16 bytes and stores up to 15 bytes
18+
inline before spilling to an `EcoVec<u8>`.
1619

1720
## Example
1821
```rust

0 commit comments

Comments
 (0)