Like a cell, but make lifetimes dynamic instead of ownership

Overview

LendingCell is a mutable container that allows you to get an owned reference to the same object. When the owned reference is dropped, ownership returns to the original container.

As opposed to a [std::cell::Cell] which moves Rust's ownership rules to runtime, a LendingCell moves Rust's lifetime rules to runtime.

The value of a LendingCell is present at construction-time, but you can convert it to a BorrowedCell<T> by calling [LendingCell::to_borrowed]. While that BorrowedCell lives (that is, until it is dropped), calling [LendingCell::try_get] will return None. The BorrowedCell has exclusive access to your type, as though you have a directly owned instance of the T, and so it is Send as long as T is Send. At last, when you drop the BorrowedCell, the T is returned to the LendingCell.

If you drop your LendingCell before dropping the BorrowedCell, then the T is dropped at the time you drop the BorrowedCell.

The invariants that Rust's memory safety rules enforce, like the single-mutable reference rule, are therefor partially ensured at compile time (you can't get two mutable references to the T), but also partially at runtime (while the BorrowedCell is active, the LendingCell behaves as though it is an Option containing None.

You might also like...
Like wee_alloc, but smaller since I used skinnier letters in the name.

lol_alloc A laughably simple wasm global_allocator. Like wee_alloc, but smaller since I used skinnier letters in the name. lol_alloc is a experimental

`0x` - like `xxd` but colorful!
`0x` - like `xxd` but colorful!

0x - like xxd but colorful! Note: for technical reasons, this library is listed as ohx on crates.io. 0x is a simple utility similar to xxd with a few

It's like monkeytype but from your terminal

DoggyType It's like monkeytype but from ur terminal (ik very unoriginal lmao) Preview doggytype-preview.mp4 Requirements: Rust Build: git clone https:

It's like pixelfix, but quix.
It's like pixelfix, but quix.

pixelquix It's like pixelfix, but quix. Written in Rust for low-level speed Uses rayon for work-stealing parallelism Based on Jump Flood for impressiv

Like HashSet but retaining INSERTION order and without `Hash` requirement on the Element type.

identified_vec A collection of unique identifiable elements which retains insertion order, inspired by Pointfree's Swift Identified Collections. Simil

An embeddable dynamic programming language for Rust.

rune Visit the site 🌐 - Read the book 📖 An embeddable dynamic programming language for Rust. Contributing If you want to help out, there should be a

Apple dynamic HEIF wallpapers on GNU/Linux.
Apple dynamic HEIF wallpapers on GNU/Linux.

timewall Apple dynamic HEIF wallpapers on GNU/Linux. Features: Support for original HEIF/HEIC dynamic wallpaper files used in MacOS. Support for all s

Dynamic dependency injection library for rust.

DDI (dynamic dependency injection) This library provides a generic dependency injection container that can be easily integrated into any application a

AI-powered game engine for dynamic, personalized experiences in evolving worlds. Ethical, accessible, inclusive.

ARCADIA: Advanced and Responsive Computational Architecture for Dynamic Interactive Ai: A Whitepaper By Reuven Cohen (rUv) Introduction Imagine a futu

Comments
Owner
Kalle Samuels
Kalle Samuels
A tool that allow you to run SQL-like query on local files instead of database files using the GitQL SDK.

FileQL - File Query Language FileQL is a tool that allow you to run SQL-like query on local files instead of database files using the GitQL SDK. Sampl

Amr Hesham 39 Mar 12, 2024
A bit like tee, a bit like script, but all with a fake tty. Lets you remote control and watch a process

teetty teetty is a wrapper binary to execute a command in a pty while providing remote control facilities. This allows logging the stdout of a process

Armin Ronacher 259 Jan 3, 2023
An implementation of Joshua Yanovski's Ghost Cell paper.

A novel safe and zero-cost borrow-checking paradigm from the GhostCell paper. Motivation A number of collections, such as linked-lists, binary-trees,

null 350 Dec 22, 2022
Statically allocated, runtime initialized cell.

static-cell Statically allocated, initialized at runtime cell. StaticCell provides a no-std-compatible, no-alloc way to reserve memory at compile time

null 4 Oct 2, 2022
Thread-safe cell based on atomic pointers to externally stored data

Simple thread-safe cell PtrCell is an atomic cell type that allows safe, concurrent access to shared data. No std, no data races, no nasal demons (UB)

Nikolay Levkovsky 3 Mar 23, 2024
du + rust = dust. Like du but more intuitive.

Dust du + rust = dust. Like du but more intuitive. Why Because I want an easy way to see where my disk is being used. Demo Install Cargo cargo install

andy.boot 5.4k Jan 4, 2023
Like grep, but uses tree-sitter grammars to search

tree-grepper Works like grep, but uses tree-sitter to search for structure instead of strings. Installing This isn't available packaged anywhere. That

Brian Hicks 219 Dec 25, 2022
Zenith - sort of like top or htop but with zoom-able charts, CPU, GPU, network, and disk usage

Zenith - sort of like top or htop but with zoom-able charts, CPU, GPU, network, and disk usage

Benjamin Vaisvil 1.6k Jan 4, 2023
A command-line shell like fish, but POSIX compatible.

A command-line shell like fish, but POSIX compatible.

Seiya Nuta 813 Dec 29, 2022
Like Lua, but in Rust, and different

AirScript It's like Lua, but in Rust, and different. Introduction AirScript is a dynamically typed, interpreted language inspired by Lua and written i

David Delassus 5 Jun 28, 2022