How can I define two-way tree structure in Rust? [duplicate]












0
















This question already has an answer here:




  • How do I express mutually recursive data structures in safe Rust?

    3 answers



  • How to model complex recursive data structures (graphs)?

    1 answer




I mean a tree where every node has multiple children and every child refers back to its parent.



I've got this far:



pub struct Post {
content: String,
links: Vec<Post>,
parent: Box<Post>,
}

impl Post {
pub fn new() -> Post {
Post {
content: String::new(),
links: Vec::new(),
parent: Box::new(......),
}
}
}


What do I put in the place of the dots?










share|improve this question















marked as duplicate by Sven Marnach, Shepmaster rust
Users with the  rust badge can single-handedly close rust questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 18:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 2





    This is a bit broad; there's an infinite amount of solutions how to implement such a tree, depending on requirements. Could you please add more information what you are trying to achieve, and what specific obstacle you hit?

    – Sven Marnach
    Nov 21 '18 at 18:45











  • Duplicate of What is the paradigmatic way to create a Rust tree with a parent pointer? (which is itself a duplicate of those two questions).

    – Shepmaster
    Nov 21 '18 at 18:54








  • 1





    Have you worked through Learning Rust With Entirely Too Many Linked Lists? It will answer many of your questions about the unique problems posed by cyclic data structures in Rust.

    – trentcl
    Nov 21 '18 at 18:55











  • See also How would you implement a bi-directional linked list in Rust?

    – Shepmaster
    Nov 21 '18 at 18:56
















0
















This question already has an answer here:




  • How do I express mutually recursive data structures in safe Rust?

    3 answers



  • How to model complex recursive data structures (graphs)?

    1 answer




I mean a tree where every node has multiple children and every child refers back to its parent.



I've got this far:



pub struct Post {
content: String,
links: Vec<Post>,
parent: Box<Post>,
}

impl Post {
pub fn new() -> Post {
Post {
content: String::new(),
links: Vec::new(),
parent: Box::new(......),
}
}
}


What do I put in the place of the dots?










share|improve this question















marked as duplicate by Sven Marnach, Shepmaster rust
Users with the  rust badge can single-handedly close rust questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 18:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 2





    This is a bit broad; there's an infinite amount of solutions how to implement such a tree, depending on requirements. Could you please add more information what you are trying to achieve, and what specific obstacle you hit?

    – Sven Marnach
    Nov 21 '18 at 18:45











  • Duplicate of What is the paradigmatic way to create a Rust tree with a parent pointer? (which is itself a duplicate of those two questions).

    – Shepmaster
    Nov 21 '18 at 18:54








  • 1





    Have you worked through Learning Rust With Entirely Too Many Linked Lists? It will answer many of your questions about the unique problems posed by cyclic data structures in Rust.

    – trentcl
    Nov 21 '18 at 18:55











  • See also How would you implement a bi-directional linked list in Rust?

    – Shepmaster
    Nov 21 '18 at 18:56














0












0








0









This question already has an answer here:




  • How do I express mutually recursive data structures in safe Rust?

    3 answers



  • How to model complex recursive data structures (graphs)?

    1 answer




I mean a tree where every node has multiple children and every child refers back to its parent.



I've got this far:



pub struct Post {
content: String,
links: Vec<Post>,
parent: Box<Post>,
}

impl Post {
pub fn new() -> Post {
Post {
content: String::new(),
links: Vec::new(),
parent: Box::new(......),
}
}
}


What do I put in the place of the dots?










share|improve this question

















This question already has an answer here:




  • How do I express mutually recursive data structures in safe Rust?

    3 answers



  • How to model complex recursive data structures (graphs)?

    1 answer




I mean a tree where every node has multiple children and every child refers back to its parent.



I've got this far:



pub struct Post {
content: String,
links: Vec<Post>,
parent: Box<Post>,
}

impl Post {
pub fn new() -> Post {
Post {
content: String::new(),
links: Vec::new(),
parent: Box::new(......),
}
}
}


What do I put in the place of the dots?





This question already has an answer here:




  • How do I express mutually recursive data structures in safe Rust?

    3 answers



  • How to model complex recursive data structures (graphs)?

    1 answer








data-structures struct tree rust






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 1:08









Shepmaster

154k14306447




154k14306447










asked Nov 21 '18 at 18:21









stensten

2,02122427




2,02122427




marked as duplicate by Sven Marnach, Shepmaster rust
Users with the  rust badge can single-handedly close rust questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 18:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Sven Marnach, Shepmaster rust
Users with the  rust badge can single-handedly close rust questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 18:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2





    This is a bit broad; there's an infinite amount of solutions how to implement such a tree, depending on requirements. Could you please add more information what you are trying to achieve, and what specific obstacle you hit?

    – Sven Marnach
    Nov 21 '18 at 18:45











  • Duplicate of What is the paradigmatic way to create a Rust tree with a parent pointer? (which is itself a duplicate of those two questions).

    – Shepmaster
    Nov 21 '18 at 18:54








  • 1





    Have you worked through Learning Rust With Entirely Too Many Linked Lists? It will answer many of your questions about the unique problems posed by cyclic data structures in Rust.

    – trentcl
    Nov 21 '18 at 18:55











  • See also How would you implement a bi-directional linked list in Rust?

    – Shepmaster
    Nov 21 '18 at 18:56














  • 2





    This is a bit broad; there's an infinite amount of solutions how to implement such a tree, depending on requirements. Could you please add more information what you are trying to achieve, and what specific obstacle you hit?

    – Sven Marnach
    Nov 21 '18 at 18:45











  • Duplicate of What is the paradigmatic way to create a Rust tree with a parent pointer? (which is itself a duplicate of those two questions).

    – Shepmaster
    Nov 21 '18 at 18:54








  • 1





    Have you worked through Learning Rust With Entirely Too Many Linked Lists? It will answer many of your questions about the unique problems posed by cyclic data structures in Rust.

    – trentcl
    Nov 21 '18 at 18:55











  • See also How would you implement a bi-directional linked list in Rust?

    – Shepmaster
    Nov 21 '18 at 18:56








2




2





This is a bit broad; there's an infinite amount of solutions how to implement such a tree, depending on requirements. Could you please add more information what you are trying to achieve, and what specific obstacle you hit?

– Sven Marnach
Nov 21 '18 at 18:45





This is a bit broad; there's an infinite amount of solutions how to implement such a tree, depending on requirements. Could you please add more information what you are trying to achieve, and what specific obstacle you hit?

– Sven Marnach
Nov 21 '18 at 18:45













Duplicate of What is the paradigmatic way to create a Rust tree with a parent pointer? (which is itself a duplicate of those two questions).

– Shepmaster
Nov 21 '18 at 18:54







Duplicate of What is the paradigmatic way to create a Rust tree with a parent pointer? (which is itself a duplicate of those two questions).

– Shepmaster
Nov 21 '18 at 18:54






1




1





Have you worked through Learning Rust With Entirely Too Many Linked Lists? It will answer many of your questions about the unique problems posed by cyclic data structures in Rust.

– trentcl
Nov 21 '18 at 18:55





Have you worked through Learning Rust With Entirely Too Many Linked Lists? It will answer many of your questions about the unique problems posed by cyclic data structures in Rust.

– trentcl
Nov 21 '18 at 18:55













See also How would you implement a bi-directional linked list in Rust?

– Shepmaster
Nov 21 '18 at 18:56





See also How would you implement a bi-directional linked list in Rust?

– Shepmaster
Nov 21 '18 at 18:56












0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

WPF add header to Image with URL pettitions [duplicate]