1use std::slice;
2
3use crate::{Document, Node};
4
5#[derive(Clone, Debug)]
7pub struct Joints<'a> {
8 pub(crate) document: &'a Document,
10
11 pub(crate) iter: slice::Iter<'a, json::Index<json::scene::Node>>,
13}
14
15impl<'a> ExactSizeIterator for Joints<'a> {}
16impl<'a> Iterator for Joints<'a> {
17 type Item = Node<'a>;
18 fn next(&mut self) -> Option<Self::Item> {
19 self.iter
20 .next()
21 .map(|index| self.document.nodes().nth(index.value()).unwrap())
22 }
23 fn size_hint(&self) -> (usize, Option<usize>) {
24 self.iter.size_hint()
25 }
26 fn count(self) -> usize {
27 self.iter.count()
28 }
29 fn last(self) -> Option<Self::Item> {
30 let document = self.document;
31 self.iter
32 .last()
33 .map(|index| document.nodes().nth(index.value()).unwrap())
34 }
35 fn nth(&mut self, n: usize) -> Option<Self::Item> {
36 self.iter
37 .nth(n)
38 .map(|index| self.document.nodes().nth(index.value()).unwrap())
39 }
40}