#Building a Tree using Rc & Refcell

11 messages · Page 1 of 1 (latest)

lavish phoenix
#

So, hi !

I'm building the tree command over the FTP protocol, I've got almost everything working... I am using the library termtree to display my tree so I'm using the Tree<D> that the library has...
My issue is that, I want to be able to build the tree using DFS and BFS without changing anything. In any other language I would have been done a few hours ago using pointers and referencing them together but I'm starting to depress on this one...

Here's my current code : https://pastebin.com/rDjNQPaF

The only issue is that whatever I try to do, my output is :

~
├── exemples
├── iir
├── public_html
├── sr1
└── test

I know that it comes from the fact that I am not storing the sub trees in the main but... How can I make it so it will be stored ?

lapis remnant
#

what output would you expect

lavish phoenix
#

I'd expect to get the whole file hierarchy

lapis remnant
#

right, so what would that look like?

#

I'm not on your system so i dont know what your actual hierarchy looks like

lavish phoenix
#

And from what my logs are telling me, I manage to parse everything... I just don't manage to link it

lapis remnant
#

i dont really see any obvious things that are wrong

#

other than that i have no idea what the Box is for, but that doens't matter for this

lavish phoenix
# lavish phoenix And from what my logs are telling me, I manage to parse everything... I just don...

Which should look like :

~
├── exemples
|   ├── parse
|   |   └── a few files...
|   └── src
|       └── a few files...
├── iir
|   ├── tp
|   └── *blurred*
├── public_html
├── sr1
|   └── TreeFTP
|       ├── a few files...
|       └── src
|           └── a few files...
└── test
    ├── aaaa
    |   ├── examples
    |   └── docs
    ├── bbbb
    └── cccc
        ├── examples
        └── others....
#

I know that I must pass a Tree to the parent Tree but if I pass it a "regular" tree I wont get the shared reference but I can't pass a Rc<RefCell<Tree<?>>> to the Tree because it needs to be an explicit Tree... D: