What is the Julia equivalent of Rust Option<T>?

Regarding performance, non type-stable stuff like missing and nothing can easily be orders of magnitude slower than the corresponding type-stable code. Whenever the type has a natural sentinel value, like NaN for floats, it’s worth using that.

See a simple example of missing being more than two orders of magnitude slower than NaN in current Julia at Is there any reason to use NaN instead of missing? - #4 by aplavin and order of magnitude type-unstable performance regression · Issue #50130 · JuliaLang/julia · GitHub.

2 Likes