DEV Community

ke na
ke na

Posted on

[Rust]Making struct for getting directory path

#[derive(Serialize, Deserialize)]
struct DirNode{
    name:String,
    children:Vec<DirNode>,
}
Enter fullscreen mode Exit fullscreen mode

1:#[derive(Serialize, Deserialize)]
Making serialize and deserialize for struct to json
2:struct DirNode{}
Making struct named DirNode
3:children:Vec
'children' retain subdirectory's list.It means to make recursively storing a list of DirNode.
DirNode can contain multiple DirNode.
So 'children' can have subdirectories.
4:Vec
Making array can have multiple values by using heap allocation.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay