]> git.lizzy.rs Git - rust.git/blob - library/std/src/sync/mpsc/cache_aligned.rs
Rollup merge of #89876 - AlexApps99:const_ops, r=oli-obk
[rust.git] / library / std / src / sync / mpsc / cache_aligned.rs
1 use crate::ops::{Deref, DerefMut};
2
3 #[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4 #[repr(align(64))]
5 pub(super) struct CacheAligned<T>(pub T);
6
7 impl<T> Deref for CacheAligned<T> {
8     type Target = T;
9     fn deref(&self) -> &Self::Target {
10         &self.0
11     }
12 }
13
14 impl<T> DerefMut for CacheAligned<T> {
15     fn deref_mut(&mut self) -> &mut Self::Target {
16         &mut self.0
17     }
18 }
19
20 impl<T> CacheAligned<T> {
21     pub(super) fn new(t: T) -> Self {
22         CacheAligned(t)
23     }
24 }