once_self_cell
owning-ref-rs
once_self_cell | owning-ref-rs | |
---|---|---|
9 | 5 | |
226 | 357 | |
- | - | |
6.8 | 0.0 | |
2 days ago | 7 months ago | |
Rust | Rust | |
Apache License 2.0 | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
once_self_cell
-
Ouroboros is also unsound
This issue says "Migrate code to use self_cell instead." That page says "It has undergone community code review from experienced Rust users." Looking at the review, issues were found and fixed earlier on, but my interpretation of the end of the thread is more that folks stopped responding with concerns, so confidence is now assumed but still not proven. The same was true of most (all?) other crates trying to solve the same problem, until enough people did find the unsoundness holes unique to each crate.
-
Announcing self_cell version 1.0
I've come across the zip example bevor, and even considered adding support for mutable access to the owner here https://github.com/Voultapher/self_cell/pull/36. See the last comment why I decided not to pursue this. Looking at the specific example, really what is the purpose of storing the lazy ZipReader result? IMO that's bit of bad design on the part of the zip crate. The stdlib APIs consume reader, allowing you to abstract over creation logic. If what you need to store, needs further pre-processing, why not pull that out? Specifically here, what is the point of having a self-referential struct that contains an owner ZipArchive that you will no longer be allowed to mutate. And a lazy reader ZipReader that you can then use to really read the file? If you need to abstract over the construction logic you could return (ZipArchive, Box ZipReader>), if you want to return the content you can return (ZipArchive, Vec) allowing further use of ZipArchive.
-
Unsoundness in owning_ref
As the author of self_cell I can attest, that writing unsafe lifetime abstractions is exceedingly tricky and you will get it wrong, repeatedly. I'm not sure these problems in owning_ref can be solved without a serious overhaul of the API. For one it tracks too little information, both ouroboros and self_cell independently reached the conclusion that you have to mark the dependent as either covariant or not_covariant over the owner lifetime, and prohibit ever leaking direct references if the dependent is not_covariant. But the fun doesn't stop there, if the owner can have a lifetime too, things get extra tricky. If you want to dive deeper take a look at this discussion https://github.com/Voultapher/self_cell/pull/29.
-
My experience crafting an interpreter with Rust
Grouping the source and derived AST in the same struct without leaking the lifetime is something that greatly helped keep the API sane. Shameless plug https://github.com/Voultapher/self_cell
-
Safe-to-use proc-macro-free self-referential structs in stable Rust.
Thanks, I'll incorporate that into https://github.com/Voultapher/once_self_cell/issues/5
owning-ref-rs
-
New C++ features in GCC 12
Increasingly feeling that Rust is like Elm: a language with novel ideas, teaching valuable lessons (a vocabulary for teaching and checking thread safety, documenting exclusive vs. shared mutability in the type system, arguably a vocabulary for teaching and checking memory safety, though that comes at a steep cost), yet so stubborn the community treats its values (avoiding shared mutability) as moral judgments of code, and the language and deliberately obstructs writing code outside of approved patterns (single ownership tree, exclusive mutability). struct{Cell...}& doesn't need to be harder to use than C++ struct{T...}*, but Rust keeps it difficult because the community views it as bad code design and wants to keep it hard. And *mut T lacks RAII unlike C++'s unique_ptr, and requires unsafe blocks in every dereference. As a result, people turn to unsound patterns like https://github.com/kimundi/owning-ref-rs, https://github.com/mcoblenz/Bronze/, and https://github.com/emu-rs/snes-apu/blob/master/src/smp.rs#L5....
It's a good language to learn. I hesitate to consider it a replacement for asm/C/C++. Writing rust is hoping that the code you're porting to rust can adapt well to the restrictions, and if not, searching for esoteric and needlessly unsafe/verbose workarounds.
-
Unsoundness in owning_ref
Note that there are other soundness issues that require more fundamental changes to be fixed.
-
Self referential return type -> (Owned, Ref<'a>)
That's a shame. I dug into owning_ref, and it looks like it has an open soundness bug as well.
What are some alternatives?
owning-ref-unsoundness - An article explaining the unsoundness I found in owning-ref
tokio - A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...
ouroboros - Easy self-referential struct generation for Rust.
string - Rust String type with configurable byte storage.
rust - Empowering everyone to build reliable and efficient software.
c2rust - Migrate C code to Rust
cxx20-modules-examples - C++20 modules examples
Bronze
advisory-db - Security advisory database for Rust crates published through crates.io
snes-apu - A Super Nintendo audio unit emulator.