Flutterby™! : Okay Rust geeks dumb newbie Q I need

Next unread comment / Catchup all unread comments User Account Info | Logout | XML/Pilot/etc versions | Long version (with comments) | Weblog archives | Site Map | | Browse Topics

Okay Rust geeks dumb newbie Q I need

2025-01-06 04:50:02.349284+01 by Dan Lyke 0 comments

Okay, Rust geeks, dumb newbie Q: I need a circular reference, so I'm going to just keep indices in a `Vec<Box<dyn ParseNode >>` arena.

The ParseNode trait has a `fn add_node(&mut self,...)` so that I can add the reference.

I want a `pub fn node(&self, idx : usize) -> &mut Box<dyn ParseNode>` to access that node, but I cannot figure out how to annotate the array to let me return the mutable reference that would let me call my `p.node(idx).add_node(other_idx)` method.

[ related topics: Handicaps & Disabilities ]

comments in ascending chronological order (reverse):

Comment policy

We will not edit your comments. However, we may delete your comments, or cause them to be hidden behind another link, if we feel they detract from the conversation. Commercial plugs are fine, if they are relevant to the conversation, and if you don't try to pretend to be a consumer. Annoying endorsements will be deleted if you're lucky, if you're not a whole bunch of people smarter and more articulate than you will ridicule you, and we will leave such ridicule in place.


Flutterby™ is a trademark claimed by

Dan Lyke
for the web publications at www.flutterby.com and www.flutterby.net.