linux_video_core/private/
internals.rs1#[derive(Clone, Copy, Debug)]
2#[repr(transparent)]
3pub struct Internal<T>(pub T);
4
5impl<T> From<T> for Internal<T> {
6 fn from(this: T) -> Self {
7 Self(this)
8 }
9}
10
11impl<T> Internal<T> {
12 pub fn into_inner(self) -> T {
13 self.0
14 }
15
16 pub fn map<R>(self, mapper: impl FnOnce(T) -> R) -> Internal<R> {
17 mapper(self.into_inner()).into()
18 }
19}
20
21impl<T> core::ops::Deref for Internal<T> {
22 type Target = T;
23
24 fn deref(&self) -> &Self::Target {
25 &self.0
26 }
27}
28
29impl<T> core::ops::DerefMut for Internal<T> {
30 fn deref_mut(&mut self) -> &mut Self::Target {
31 &mut self.0
32 }
33}
34
35impl<T> AsRef<T> for Internal<T> {
36 fn as_ref(&self) -> &T {
37 &self.0
38 }
39}
40
41impl<T> AsMut<T> for Internal<T> {
42 fn as_mut(&mut self) -> &mut T {
43 &mut self.0
44 }
45}
46
47impl<T: core::fmt::Display> core::fmt::Display for Internal<T> {
48 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
49 self.0.fmt(f)
50 }
51}