From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- third_party/rust/yoke/README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 third_party/rust/yoke/README.md (limited to 'third_party/rust/yoke/README.md') diff --git a/third_party/rust/yoke/README.md b/third_party/rust/yoke/README.md new file mode 100644 index 0000000000..23c1ac8c38 --- /dev/null +++ b/third_party/rust/yoke/README.md @@ -0,0 +1,31 @@ +# yoke [![crates.io](https://img.shields.io/crates/v/yoke)](https://crates.io/crates/yoke) + + + +This crate provides [`Yoke`][Yoke], which allows one to "yoke" (attach) a zero-copy deserialized +object (say, a [`Cow<'a, str>`](alloc::borrow::Cow)) to the source it was deserialized from, (say, an [`Rc<[u8]>`](alloc::rc::Rc)), +known in this crate as a "cart", producing a type that looks like `Yoke, Rc<[u8]>>` +and can be moved around with impunity. + +Succinctly, this allows one to "erase" static lifetimes and turn them into dynamic ones, similarly +to how `dyn` allows one to "erase" static types and turn them into dynamic ones. + +Most of the time the yokeable `Y` type will be some kind of zero-copy deserializable +abstraction, potentially with an owned variant (like [`Cow`](alloc::borrow::Cow), +[`ZeroVec`](https://docs.rs/zerovec), or an aggregate containing such types), and the cart `C` will be some smart pointer like + [`Box`](alloc::boxed::Box), [`Rc`](alloc::rc::Rc), or [`Arc`](std::sync::Arc), potentially wrapped in an [`Option`](Option). + +The key behind this crate is [`Yoke::get()`], where calling [`.get()`][Yoke::get] on a type like +`Yoke, _>` will get you a short-lived `&'a Cow<'a, str>`, restricted to the +lifetime of the borrow used during [`.get()`](Yoke::get). This is entirely safe since the `Cow` borrows from +the cart type `C`, which cannot be interfered with as long as the `Yoke` is borrowed by [`.get()`](Yoke::get). +[`.get()`](Yoke::get) protects access by essentially reifying the erased lifetime to a safe local one +when necessary. + +See the documentation of [`Yoke`] for more details. + + + +## More Information + +For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x). -- cgit v1.2.3