This content originally appeared on DEV Community and was authored by ke na
#[derive(Serialize, Deserialize)]
struct DirNode{
name:String,
children:Vec<DirNode>,
}
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.
This content originally appeared on DEV Community and was authored by ke na

ke na | Sciencx (2024-07-21T22:10:17+00:00) [Rust]Making struct for getting directory path. Retrieved from https://www.scien.cx/2024/07/21/rustmaking-struct-for-getting-directory-path/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.