Created
December 13, 2020 18:35
-
-
Save Heimdell/863df984e88707857d4b34878f2b945f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::sync::Arc; | |
enum Octree<B, A> | |
{ Branch | |
{ preview : B | |
, subtrees : [Arc<Octree<B, A>>; 8] | |
} | |
, Atom | |
{ leaf : A | |
, preview : B | |
} | |
} | |
type Path = Vec<usize>; | |
trait IsOctree<'bounded> { | |
fn lookup(path : Path, it : &'bounded Arc<Self>) -> &'bounded Arc<Self>; | |
// fn update(path : Path, value : Self, it : &Self) -> Self; | |
} | |
impl <'bounded, A : 'static, B : 'static> IsOctree<'bounded> for Octree<B, A> { | |
fn lookup(path : Path, it : &'bounded Arc<Octree <B, A>>) -> &'bounded Arc<Octree<B, A>> { | |
let mut ptr = it; | |
for i in path { | |
match &**ptr { | |
| Octree::Atom {leaf, preview} => return &ptr, | |
| Octree::Branch {preview, subtrees} => | |
ptr = &subtrees[i] | |
} | |
} | |
return &it | |
} | |
// fn update(path : Path, val : Octree <B, A>, it : &Octree <B, A>) -> Octree<B, A> { | |
// return *it | |
// } | |
} | |
fn main() { | |
println!("Hello, world!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment