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
use std::cell::Cell;
use std::mem::MaybeUninit;
pub trait AssignElem<T> {
fn assign_elem(self, input: T);
}
impl<'a, T> AssignElem<T> for &'a mut T {
fn assign_elem(self, input: T) {
*self = input;
}
}
impl<'a, T> AssignElem<T> for &'a Cell<T> {
fn assign_elem(self, input: T) {
self.set(input);
}
}
impl<'a, T> AssignElem<T> for &'a mut MaybeUninit<T> {
fn assign_elem(self, input: T) {
*self = MaybeUninit::new(input);
}
}