dimanche 24 janvier 2021

Build a UrlTree from Vec

i'm need to make url tree struct, like a sitemap. Input: Vec - list of url Expected Output: struct with nested hierarhy of url's, from root to endpoints.

Does it already existed crate or i need to make it myself?

Input:

{
   "https://exapmle.com",
   "https://exapmle.com/aa",
   "https://exapmle.com/ab",
   "https://exapmle.com/v",
   "https://exapmle.com/zac",
   "https://exapmle.com/zac/acf",
   "https://exapmle.com/zac/acf/adr",
   "https://exapmle.com/zac/axx"
}

Output:

UrlTree {
    root: "https://exapmle.com",
    Nodes: {
        {
            node: "aa",
            Nodes: None,
        },
        {
            node: "ab",
            Nodes: None,
        },
        {
            node: "v",
            Nodes: None,
        },
        {
            node: "zac",
            Nodes: {
                       {
                            node: "acf",
                            Nodes: {
                                       node: "adr",
                                       Nodes: None,
                                   }   
                       },
                       {
                            node: "axx",
                            Nodes: None,
                       }
                   }
        }
    }
}



Aucun commentaire:

Enregistrer un commentaire