Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic maskedstorage #668

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add contains method to MaskedStorage
Rua committed Jan 9, 2020
commit aff96a8dae7e5edbda25fc172ad7e8b740934123
5 changes: 5 additions & 0 deletions src/storage/mod.rs
Original file line number Diff line number Diff line change
@@ -157,6 +157,11 @@ impl<S: UnprotectedStorage> MaskedStorage<S> {
self.mask.clear();
}

/// Check if the given id refers to a valid element in the storage.
pub fn contains(&self, id: Index) -> bool {
self.mask.contains(id)
}

/// Get an element by a given index.
pub fn get(&self, id: Index) -> Option<&S::Item> {
if self.mask.contains(id) {