FAQ
Why Use The Rust Package Even If I Don't Know Rust Language?
From a language perspective we believe Dart is sadly lacking in a few areas, of which this package solves:
- Dart utilizes unchecked try/catch exceptions. Handling errors as values is preferred for maintainability, thus the
Resulttype. - Dart has nullable types but you cannot do null or non-null specific operations without a bunch of
ifstatements and bugs may be introduced due toT??not being possible.Option<T>fixes this with no runtime cost and you can easily switch back and forth. - Dart is missing the functionality of Rust's early return operator (
?) operator, so we implemented it in Dart. - Dart is missing a built in
Celltype or equivalent (andOnceCell/LazyCell). - Dart's
Listtype is an array/vector union (it's growable or non-growable). This is not viewable at the type layer, which may lead to runtime exceptions and encourages using growableLists everywhere even when you do not need to, which is less performant. So we addedArr(array). - Dart has no concept of a slice type, so allocating sub-lists is the only method, which is not that efficient. So we added
Slice<T>. - Dart's between isolate communication is by ports (
ReceivePort/SendPort), which is untyped and horrible, we standardized this with introducingchannelfor typed bi-directional isolate communication. - Dart's iteration methods are lacking for
IterableandIterator(there are none! justmoveNext()andcurrent), while Rust has an abundance of useful methods. So we introduced Rust'sIteratorasIter. - Dart does not have built in path manipulation. So, we added
Path, a zero cost extension type ofStringfor path manipulation. - Dart's
File/Directory/Linkabstraction was the wrong choice and prone to exceptions. We believeFsandPathare a stronger and safer alternative. - No built in cross-platform environment introspect -
Platformdoes not work on web. So we addedEnvwhich is cross-platform.
I Know Rust, Can This Package Benefit My Team and I?
Absolutely! In fact, our team both programs in and love Dart and Rust. From a team and user perspective, having one common api across two different languages greatly increases our development velocity in a few ways:
- Context switching is minimized, the api's across the two languages are the same.
- Shrinking the knowledge gap between Rust and Dart developers.