cached_proc_macro_types/lib.rs
1/// Used to wrap a function result so callers can see whether the result was cached.
2#[derive(Clone)]
3pub struct Return<T> {
4 pub was_cached: bool,
5 pub value: T,
6}
7
8impl<T> Return<T> {
9 pub fn new(value: T) -> Self {
10 Self {
11 was_cached: false,
12 value,
13 }
14 }
15}
16
17impl<T> std::ops::Deref for Return<T> {
18 type Target = T;
19
20 fn deref(&self) -> &Self::Target {
21 &self.value
22 }
23}
24
25impl<T> std::ops::DerefMut for Return<T> {
26 fn deref_mut(&mut self) -> &mut Self::Target {
27 &mut self.value
28 }
29}