-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduces `Shared` and `SharedExt` as a convenience typ and trait that turn ```rust use std::sync::{Arc, RwLock}; let lock = Arc::new(RwLock::new(42)); assert_eq!(*lock.try_read().unwrap(), 42); ``` into ```rust use std::sync::{Arc, RwLock}; use xrcf::shared::{Shared, SharedExt}; let lock = Shared::new(42.into()); assert_eq!(*lock.re(), 42); ``` This is a tradeoff between making it easier to use the `Arc<RwLock<T>>` while also not wrapping it in a completely different object which would add another layer of indirection. The most important thing is now that thanks to `SharedExt`, writing `lock.rd().` lists the available methods. This is much easier to quickly check the available methods than via `lock.try_read().unwrap().`. Another benefit is that `re` is much shorter so it's more likely to fit into one line. One-liners work particularly well in Rust do to when variables are freed, see https://xrcf.org/blog/iterators/ for more information.
- Loading branch information
1 parent
ed7ebfb
commit 382d067
Showing
40 changed files
with
992 additions
and
1,196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.