Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_raw_ancestor none with multiple children #64

Open
sampaioletti opened this issue Feb 5, 2021 · 0 comments
Open

get_raw_ancestor none with multiple children #64

sampaioletti opened this issue Feb 5, 2021 · 0 comments

Comments

@sampaioletti
Copy link

Very sure this is from my lack of understanding of a radix tree...but can someone tell me why the second test fails pls. Thanks in advance.

    #[test]
    fn test_example() {
        let mut t = Trie::new();
        t.insert("/1", "1");
        t.insert("/1/1.1", "1.1");
        t.insert("/1/1.2", "1.2");
        t.insert("/1/1.3", "1.3");
        // t.insert("/2", "2");
        let v: Vec<&str> = t
            .get_raw_ancestor("")
            .children()
            .map(|s| *s.value().unwrap())
            .collect();

        let mut iter = v.iter();
        assert!(*iter.next().unwrap() == "1");
        assert!(iter.next().is_none());
    }
    #[test]
    fn test_example_fails() {
        let mut t = Trie::new();
        t.insert("/1", "1");
        t.insert("/1/1.1", "1.1");
        t.insert("/1/1.2", "1.2");
        t.insert("/1/1.3", "1.3");
        t.insert("/2", "2"); // <- uncommented
        let v: Vec<&str> = t
            .get_raw_ancestor("")
            .children()
            .map(|s| *s.value().unwrap()) //<-panics
            .collect();

        let mut iter = v.iter();
        assert!(*iter.next().unwrap() == "1");
        assert!(*iter.next().unwrap() == "2");
        assert!(iter.next().is_none());
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant