Possible to implement recursive data structures in safe Rust?

⚓ Rust    📅 2025-09-16    👤 surdeus    👁️ 10      

surdeus

Warning

This post was published 47 days ago. The information described in this article may have changed.

In my learning experience I can not figure out how to implement basic data structures like Single Linked Lists, Binary Trees or Directed Graphs in safe Rust. Especially for element removal operations I have had to resort to unsafe Rust. Either directly with unsafe block or indirectly with standard library auxiliary functions like mem::take or mem::replace. All due to borrow checker prevented have two mutable accesses to the same instance.

I'm curious if there is any implementation of some of above DS which does not require unsafe Rust?

4 posts - 4 participants

Read full topic

🏷️ Rust_feed