Skip to content

Commit

Permalink
Merge branch 'master' into enhance-readme-with-screencast-visualization-
Browse files Browse the repository at this point in the history
  • Loading branch information
juandiegocv27 authored Aug 13, 2024
2 parents 5bc76de + 3acc8a6 commit 44f4c73
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @frol @agostbiro @uint
* @frol @dj8yfo @ruseinov @akorchyn
14 changes: 14 additions & 0 deletions near-sdk/src/store/lazy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ where
}
}
}

/// Removes the underlying storage item. Useful for deprecating the obsolete [`Lazy`] values.
pub fn remove(&mut self) -> bool {
env::storage_remove(&self.storage_key)
}
}

impl<T> Lazy<T>
Expand Down Expand Up @@ -185,6 +190,15 @@ mod tests {
assert_eq!(lazy_loaded, b);
}

#[test]
pub fn test_remove() {
let mut lazy = Lazy::new(b"m", 8u8);
lazy.flush();
assert!(env::storage_has_key(b"m"));
lazy.remove();
assert!(!env::storage_has_key(b"m"));
}

#[test]
pub fn test_debug() {
let mut lazy = Lazy::new(b"m", 8u8);
Expand Down

0 comments on commit 44f4c73

Please sign in to comment.