Hacker News new | ask | show | jobs
by ridiculous_fish 1645 days ago
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.