Get the latest tech news

Creating an empty iterator of a certain type in Rust (2018)


I am working these days on the development of offset's Index server. I needed to implement a basic directed graph structure, allowing to run the BFS algorithm to find routes with a certain amount of capacity.

I needed to implement a basic directed graph structure, allowing to run the BFS algorithm to find routes with a certain amount of capacity. The details about the send and receive capacities are not very relevant to the discussion here, but I felt obligated to explain the non matching numbers in the example above. This is a working solution, however, note that we allocate a vector every time we call this function, and where is the fun in using Rust if we don't have zero cost abstractions?

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Rust

Rust

Photo of certain type

certain type

Photo of iterator

iterator

Related news:

News photo

Google says replacing C/C++ in firmware with Rust is easy

News photo

Build a quick Local code intelligence using Ollama with Rust

News photo

Deploying rust in existing firmware codebases