Text search library in Rust, day 1

I’ve played around a bit with Rust—mostly at the urging of my friend, Ryan Levick, who advocates for the use of Rust here at Microsoft—but it’s been hard for me to come up with a reason to choose Rust over other languages for the programming projects in my life. Historically, I’ve been more focused on building macOS and iOS apps using Objective-C and Swift. My current team at Microsoft, in turn, is focused on building world-class services using C# and .NET. In neither case would it make much sense to replace Swift or C# with Rust, since the languages I’m using are already memory-safe and better integrated into their ecosystems.

However, one of the personal projects I’ve worked on in the past is just itching for a rewrite. GNETextSearch is a simple search engine powered by ternary trees and written in C. Ding ding! It’s a stable library in use by apps with hundreds of thousands of users. However, it does have one glaring flaw: the ternary trees are implemented recursively, which means that, in very rare cases, it’s susceptible to stack overflows. I’ve been wanting to replace its recursive methods with loops.

So, I’ve decided to learn Rust by rewriting GNETextSearch in Rust. Let’s see how this goes.


I’m rewriting my GNETextSearch C library in Rust.