We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This crate: https://docs.rs/ref_filter_map/1.0.1/ref_filter_map/ allow to deal with guard and options using an unsafe operation. The core of the crate is this code:
pub fn ref_filter_map< T: ?Sized, U: ?Sized, F: FnOnce(&T) -> Option<&U> >(orig: Ref<T>, f: F) -> Option<Ref<U>> { f(&orig) .map(|new| new as *const U) .map(|raw| Ref::map(orig, |_| unsafe { &*raw })) }
Would translating the previous code snipped to RwLock works safely?
pub fn rwlock_filter_map< T: ?Sized, U: ?Sized, F: FnOnce(&T) -> Option<&U> >(orig: MappedRwLockReadGuard<T>, f: F) -> Option<MappedRwLockReadGuard<U>> { f(&orig) .map(|new| new as *const U) .map(|raw| MappedRwLockReadGuard::map(orig, |_| unsafe { &*raw })) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
This crate: https://docs.rs/ref_filter_map/1.0.1/ref_filter_map/ allow to deal with guard and options using an unsafe operation.
The core of the crate is this code:
Would translating the previous code snipped to RwLock works safely?
The text was updated successfully, but these errors were encountered: