# Why Rust made an XML tree a lesson in software design

**Summary:** Martijn Faassen's Rust essay shows how ownership rules reshape an XML tree's storage, and why the same design pressure can help learning but hinder rapid prototyping.

- Canonical: https://markhuang.ai/news/rust-xml-tree-ownership
- Language: en
- Author: [Mark Huang](https://markhuang.ai/about)
- Published: 2026-11-16
- Section: News
- Tags: Rust, Software Design, Ownership, XML, Programming Languages
- Source: [Martijn Faassen's Secret Weblog](https://blog.startifact.com/posts/how-rust-changed-me/)
- License: https://creativecommons.org/licenses/by-nc/4.0/

---

![A rust-orange gear frames a branching tree of ivory blocks rising from one compact storage tray](https://cdn.markhuang.ai/news/rust-xml-tree-ownership/hero.webp)

*Conceptual illustration: a tree's links and the storage beneath them. Generated with imagegen.*

Martijn Faassen wanted an XML tree he could edit and navigate in both directions: down to a node's children and back up to its parent. In [his essay on how Rust changed him as a developer](https://blog.startifact.com/posts/how-rust-changed-me/), he describes finding libraries that allowed edits but lacked parent links. That gap, along with missing XML features, helped prompt him to build Xot, his own XML library.

His November 16, 2026 essay reflects on more than six years using Rust, including more than four professionally. The interesting change is in his design habits. Rust's restrictions pushed him to separate the relationships between pieces of data from responsibility for storing them. That makes a tree a useful example even for readers who never plan to write Rust.

A programming language can make familiar problems look different. Faassen describes reconsidering which states his programs should allow and how much data he could keep in memory. The value for a reader is seeing how those decisions change what he can build.

## A parent link is not the same as ownership

XML represents structured documents. A tree lets software follow nested elements, much as folders contain other folders. Looking downward is straightforward; looking upward requires a way to find the parent again. Once both directions exist, the relationships form a loop.

The difficulty in Rust is deciding who owns the data and who merely borrows access to it. The [Rust Book's borrowing rules](https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html) explain an important constraint: ordinary references allow shared read access or exclusive mutable access to a value at a time. Those rules make freely connected, independently editable objects harder to arrange.

Faassen describes an alternative called an arena: put the nodes together in a store and use indexes to refer to them. A child can record its parent's index, and the parent can record its children's indexes. The store owns the nodes; those links describe relationships without requiring each node to own the other.

```mermaid
flowchart TD
    S["Arena: common node storage"] -->|owns| P["Parent node"]
    S -->|owns| C["Child node"]
    P -. child index .-> C
    C -. parent index .-> P
```

This diagram shows the distinction, rather than Xot's exact internal layout. The [Xot documentation](https://docs.rs/xot/latest/xot/) shows how a caller uses the library: one `Xot` object manages XML data, while lightweight `Node` handles identify nodes for access and editing.

I find that separation useful: being connected to something does not have to mean being responsible for its storage. It gives a developer a way to preserve a useful relationship while changing how the program manages the data underneath.

## Describe the cases before handling them

Another change Faassen describes concerns enums, Rust's way of expressing a value that can be one of several distinct variants. His examples include a result that holds either a successful value or an error. Each case carries the information appropriate to it.

The benefit is easier to understand as a design question: which situations are possible, and what does each situation need? Once those choices are explicit, code can handle them separately. The [Rust Book's explanation of `match`](https://doc.rust-lang.org/book/ch06-02-match.html) confirms that the compiler checks whether all possible cases are covered. If code names every variant individually, adding another can reveal places that need updating. A catch-all branch changes that behavior by covering otherwise unlisted cases.

Faassen contrasts this with defining a common interface for different kinds of objects. Such an interface can be worthwhile when outside code needs to supply new implementations. For a known set of cases inside one application, an enum may express the problem more directly.

His lesson is also iterative. Writing types can expose an unclear design, just as writing documentation or tests can. He explicitly argues for returning to those types as understanding develops, rather than specifying everything before implementation begins.

## The same friction can interrupt an experiment

[LogLog Games' April 2024 account of leaving Rust game development](https://loglog.games/blog/leaving-rust-gamedev/) describes the cost of that pressure. The author reports having to refactor code to satisfy the compiler while trying to test gameplay ideas, including code intended to be disposable. The account also acknowledges Rust's help with large refactorings. The objection is about when that work becomes necessary.

That distinction matters when applying Faassen's experience. If the goal is to understand a system's ownership, an enforced redesign may be productive. If the goal is to find out whether a game mechanic is fun, stopping to redesign the surrounding code may delay the answer the project needs.

Both essays report experience; neither is a controlled comparison of developer productivity. My reading is that a constraint's usefulness depends partly on whether it forces a decision worth making at that moment. A language-learning project and a prototype on a deadline can reasonably value that interruption differently.

## Efficiency can change the design you consider

Faassen's final example is [Colchis](https://blog.startifact.com/posts/how-rust-changed-me/#performance-has-a-quality-all-its-own), his experiment with storing large amounts of JSON data in memory while retaining access, including indexed access. He says this possibility had not been on his radar before Rust. The essay gives no comparative benchmark or memory budget, so it cannot establish how much another application would save.

If data can fit comfortably in memory, would you organize the program differently? Faassen credits Rust with making such possibilities easier for him to see. His interest is in attempting a design he had not previously considered, as well as making existing operations faster.

For someone curious about Rust, a small editable tree is a concrete learning exercise suggested by this essay. Work out where the nodes live, how links find them, and which operations may change them. Even if the next project uses another language, those ownership questions remain useful. The payoff Faassen describes is having more designs available when he sits down to solve a problem.
