Hacker News new | past | comments | ask | show | jobs | submit login

I struggle with even non-cyclic linked data structures in Rust. For example consider a binary tree:

    struct Node {
      value: usize,
      left: Option<Box<Node>>,
      right: Option<Box<Node>>,
    }
I want to write a function to increment the value of every Node. This is trivial with recursion, but that risks blowing the stack. So I try an iterative version using an explicit stack, but the borrow checker doesn't understand explicit stacks, only the C stack, so it rejects my code.

There's no inherent underlying complexity to transforming a recursive function to an iterative one, yet it is legitimately hard in Rust.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: