feat: add qcell
This commit is contained in:
25
__concurrent/qcell/Cargo.lock
generated
Normal file
25
__concurrent/qcell/Cargo.lock
generated
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "qcell"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"qcell 0.5.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "qcell"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e5023f06b72bfa9fbb5ebdbe891f02db9406ba026990e0778f80094bc84f3ac8"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
10
__concurrent/qcell/Cargo.toml
Normal file
10
__concurrent/qcell/Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "qcell"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
qcell = "0.5.0"
|
||||||
|
|
||||||
16
__concurrent/qcell/src/main.rs
Normal file
16
__concurrent/qcell/src/main.rs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
use std::rc::Rc;
|
||||||
|
use qcell::{QCell, QCellOwner};
|
||||||
|
|
||||||
|
// https://docs.rs/qcell/latest/qcell/
|
||||||
|
fn main() {
|
||||||
|
let mut owner = QCellOwner::new();
|
||||||
|
|
||||||
|
let item = Rc::new(QCell::new(&owner, Vec::<u8>::new()));
|
||||||
|
let iref = owner.rw(&item);
|
||||||
|
// test(&mut owner, &item); // Compile error
|
||||||
|
iref.push(1);
|
||||||
|
|
||||||
|
fn test(owner: &mut QCellOwner, item: &Rc<QCell<Vec<u8>>>) {
|
||||||
|
owner.rw(&item).push(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user