• Home
Name Date Size #Lines LOC

..--

src/04-Jul-2025-3,1651,038

tests/04-Jul-2025-10070

.android-checksum.jsonD04-Jul-20251.8 KiB11

.cargo-checksum.jsonD04-Jul-20251.3 KiB11

Android.bpD04-Jul-20251.2 KiB5349

Cargo.tomlD04-Jul-20252.3 KiB118102

LICENSED04-Jul-20252.1 KiB4736

METADATAD04-Jul-2025416 1817

MODULE_LICENSE_UNICODE_3D04-Jul-20250

README.mdD04-Jul-20251.8 KiB3222

cargo_embargo.jsonD04-Jul-2025332 1818

icu4x_bionic_dep.bp.fragmentD04-Jul-202561 55

README.md

1# yoke [![crates.io](https://img.shields.io/crates/v/yoke)](https://crates.io/crates/yoke)
2
3<!-- cargo-rdme start -->
4
5This crate provides [`Yoke<Y, C>`][Yoke], which allows one to "yoke" (attach) a zero-copy deserialized
6object (say, a [`Cow<'a, str>`](alloc::borrow::Cow)) to the source it was deserialized from, (say, an [`Rc<[u8]>`](alloc::rc::Rc)),
7known in this crate as a "cart", producing a type that looks like `Yoke<Cow<'static, str>, Rc<[u8]>>`
8and can be moved around with impunity.
9
10Succinctly, this allows one to "erase" static lifetimes and turn them into dynamic ones, similarly
11to how `dyn` allows one to "erase" static types and turn them into dynamic ones.
12
13Most of the time the yokeable `Y` type will be some kind of zero-copy deserializable
14abstraction, potentially with an owned variant (like [`Cow`](alloc::borrow::Cow),
15[`ZeroVec`](https://docs.rs/zerovec), or an aggregate containing such types), and the cart `C` will be some smart pointer like
16  [`Box<T>`](alloc::boxed::Box), [`Rc<T>`](alloc::rc::Rc), or [`Arc<T>`](std::sync::Arc), potentially wrapped in an [`Option<T>`](Option).
17
18The key behind this crate is [`Yoke::get()`], where calling [`.get()`][Yoke::get] on a type like
19`Yoke<Cow<'static, str>, _>` will get you a short-lived `&'a Cow<'a, str>`, restricted to the
20lifetime of the borrow used during [`.get()`](Yoke::get). This is entirely safe since the `Cow` borrows from
21the cart type `C`, which cannot be interfered with as long as the `Yoke` is borrowed by [`.get()`](Yoke::get).
22[`.get()`](Yoke::get) protects access by essentially reifying the erased lifetime to a safe local one
23when necessary.
24
25See the documentation of [`Yoke`] for more details.
26
27<!-- cargo-rdme end -->
28
29## More Information
30
31For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x).
32