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
#[cfg(feature = "serialize")]
extern crate serde;
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
#[derive(Debug)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub struct OctreeNode<L, D> {
pub loc_code: L,
pub data: D,
}
impl<L, D> OctreeNode<L, D> {
pub(crate) fn new(data: D, loc_code: L) -> Self {
Self { data, loc_code }
}
pub(crate) fn transform<U>(self) -> OctreeNode<L, U>
where
U: From<D>,
{
OctreeNode {
loc_code: self.loc_code,
data: U::from(self.data),
}
}
pub(crate) fn transform_fn<U, F>(self, function: F) -> OctreeNode<L, U>
where
F: Fn(D) -> U,
{
OctreeNode {
loc_code: self.loc_code,
data: function(self.data),
}
}
}