1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#![allow(incomplete_features)]
#![feature(
generic_associated_types,
allocator_api,
alloc_layout_extra,
nonnull_slice_from_raw_parts,
slice_ptr_len,
ptr_metadata,
maybe_uninit_slice,
generic_const_exprs,
thread_local,
once_cell,
layout_for_ptr,
)]
pub mod device;
pub mod ptr;
pub mod vec;
pub mod zero;
pub mod boxed;
pub trait Share {
type Ref<'a>
where
Self: 'a;
fn share(&self) -> Self::Ref<'_>;
}
pub trait ShareMut {
type Mut<'a>
where
Self: 'a;
fn share_mut(&mut self) -> Self::Mut<'_>;
}
impl<D: std::ops::Deref> Share for D {
type Ref<'a>
where
Self: 'a,
= &'a D::Target;
fn share(&self) -> Self::Ref<'_> {
self
}
}
impl<D: std::ops::DerefMut> ShareMut for D {
type Mut<'a>
where
Self: 'a,
= &'a mut D::Target;
fn share_mut(&mut self) -> Self::Mut<'_> {
self
}
}