aboutsummaryrefslogtreecommitdiff
path: root/vendor/addr2line/src/lazy.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/addr2line/src/lazy.rs
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/addr2line/src/lazy.rs')
-rw-r--r--vendor/addr2line/src/lazy.rs31
1 files changed, 0 insertions, 31 deletions
diff --git a/vendor/addr2line/src/lazy.rs b/vendor/addr2line/src/lazy.rs
deleted file mode 100644
index 2df2ed6..0000000
--- a/vendor/addr2line/src/lazy.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-use core::cell::UnsafeCell;
-
-pub struct LazyCell<T> {
- contents: UnsafeCell<Option<T>>,
-}
-impl<T> LazyCell<T> {
- pub fn new() -> LazyCell<T> {
- LazyCell {
- contents: UnsafeCell::new(None),
- }
- }
-
- pub fn borrow(&self) -> Option<&T> {
- unsafe { &*self.contents.get() }.as_ref()
- }
-
- pub fn borrow_with(&self, closure: impl FnOnce() -> T) -> &T {
- // First check if we're already initialized...
- let ptr = self.contents.get();
- if let Some(val) = unsafe { &*ptr } {
- return val;
- }
- // Note that while we're executing `closure` our `borrow_with` may
- // be called recursively. This means we need to check again after
- // the closure has executed. For that we use the `get_or_insert`
- // method which will only perform mutation if we aren't already
- // `Some`.
- let val = closure();
- unsafe { (*ptr).get_or_insert(val) }
- }
-}