Added root ids.
This commit is contained in:
		@@ -15,6 +15,7 @@ struct IDPath {
 | 
				
			|||||||
impl IDPath {
 | 
					impl IDPath {
 | 
				
			||||||
    fn new() -> Self {
 | 
					    fn new() -> Self {
 | 
				
			||||||
        let mut path = Vec::new();
 | 
					        let mut path = Vec::new();
 | 
				
			||||||
 | 
					        path.push(Uuid::nil());
 | 
				
			||||||
        Self { path: path }
 | 
					        Self { path: path }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -24,7 +25,9 @@ impl IDPath {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    fn extend(&self, addition: Uuid) -> Self {
 | 
					    fn extend(&self, addition: Uuid) -> Self {
 | 
				
			||||||
        let mut result = self.clone();
 | 
					        let mut result = self.clone();
 | 
				
			||||||
 | 
					        result.path.pop();
 | 
				
			||||||
        result.path.push(addition);
 | 
					        result.path.push(addition);
 | 
				
			||||||
 | 
					        result.path.push(Uuid::nil());
 | 
				
			||||||
        result
 | 
					        result
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -39,8 +42,9 @@ mod ids {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    #[test]
 | 
					    #[test]
 | 
				
			||||||
    fn create_idpath() {
 | 
					    fn create_idpath() {
 | 
				
			||||||
 | 
					        let expected = [Uuid::nil()];
 | 
				
			||||||
        let id = IDPath::new();
 | 
					        let id = IDPath::new();
 | 
				
			||||||
        assert_eq!(id.path.len(), 0);
 | 
					        assert_eq!(id.path, expected);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[test]
 | 
					    #[test]
 | 
				
			||||||
@@ -56,20 +60,18 @@ mod ids {
 | 
				
			|||||||
    #[test]
 | 
					    #[test]
 | 
				
			||||||
    fn extend_idpath() {
 | 
					    fn extend_idpath() {
 | 
				
			||||||
        let mut path: Vec<Uuid> = Vec::new();
 | 
					        let mut path: Vec<Uuid> = Vec::new();
 | 
				
			||||||
 | 
					        path.push(Uuid::nil());
 | 
				
			||||||
        let mut id = IDPath::new();
 | 
					        let mut id = IDPath::new();
 | 
				
			||||||
        for _ in 1..5 {
 | 
					        for count in 1..5 {
 | 
				
			||||||
 | 
					            assert_eq!(id.path.len(), count);
 | 
				
			||||||
            let extended = IDPath::next();
 | 
					            let extended = IDPath::next();
 | 
				
			||||||
            id = id.extend(extended.clone());
 | 
					            id = id.extend(extended.clone());
 | 
				
			||||||
 | 
					            path.pop();
 | 
				
			||||||
            path.push(extended);
 | 
					            path.push(extended);
 | 
				
			||||||
 | 
					            path.push(Uuid::nil());
 | 
				
			||||||
            assert_eq!(id.path, path);
 | 
					            assert_eq!(id.path, path);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    #[test]
 | 
					 | 
				
			||||||
    fn get_root() {
 | 
					 | 
				
			||||||
        let mut id = IDPath::new();
 | 
					 | 
				
			||||||
        id.root();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct Cache {
 | 
					struct Cache {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user