https://github.com/mcmah309/rust
A pure Dart implementation of patterns found in the Rust programming language. Types include Result, Option, Cell, Slice, Array, Iterator, etc. Facilitates functional programming and error handling.
https://github.com/mcmah309/rust
dart rust
Last synced: 12 months ago
JSON representation
A pure Dart implementation of patterns found in the Rust programming language. Types include Result, Option, Cell, Slice, Array, Iterator, etc. Facilitates functional programming and error handling.
- Host: GitHub
- URL: https://github.com/mcmah309/rust
- Owner: mcmah309
- License: mit
- Created: 2023-11-30T18:01:06.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-23T01:20:21.000Z (over 1 year ago)
- Last Synced: 2025-06-25T08:03:07.410Z (about 1 year ago)
- Topics: dart, rust
- Language: Dart
- Homepage:
- Size: 1000 KB
- Stars: 132
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://pub.dev/packages/rust)
[](https://pub.dev/documentation/rust/latest/)
[](https://opensource.org/licenses/MIT)
[](https://github.com/mcmah309/rust/actions)
[rust](https://github.com/mcmah309/rust) (formally known as [rust_core](https://pub.dev/packages/rust_core)) is a pure Dart implementation of patterns found in the [Rust programming language](https://www.rust-lang.org/), bringing powerful tools previously only available to Rust developers to Dart developers!
New types include [Result](https://mcmah309.github.io/rust/libs/result/result.html), [Option](https://mcmah309.github.io/rust/libs/option/option.html), [Cell](https://mcmah309.github.io/rust/libs/cell/cell.html), [Slice](https://mcmah309.github.io/rust/libs/slice/slice.html), [Array](https://mcmah309.github.io/rust/libs/array/array.html), [Iterator](https://mcmah309.github.io/rust/libs/iter/iter.html), [Channels](https://mcmah309.github.io/rust/libs/sync/channels.html), [Mutex](https://mcmah309.github.io/rust/libs/sync/mutex.html), [Path](https://mcmah309.github.io/rust/libs/path/path.html) and more.
See the [Documentation Book 📖](https://mcmah309.github.io/rust) for a deeper dive!
### Example: Rust Language vs rust Package
---
> Goal: Get the index of every "!" in a string not followed by a "?"
**[Rust](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=f8a2979808d21a7bfe22a3cfb70ec389):**
```rust
use std::iter::Peekable;
fn main() {
let string = "kl!sd!?!";
let mut answer: Vec = Vec::new();
let mut iter: Peekable<_> = string
.chars()
.map_windows(|w: &[char; 2]| *w)
.enumerate()
.peekable();
while let Some((index, window)) = iter.next() {
match window {
['!', '?'] => continue,
['!', _] => answer.push(index),
[_, '!'] if iter.peek().is_none() => answer.push(index + 1),
_ => continue,
}
}
println!("{:?}", answer); // [2, 7]
}
```
**Dart:**
```dart
import 'package:rust/rust.dart';
void main() {
final string = "kl!sd!?!";
Vec answer = [];
Peekable<(int, Arr)> iter = string
.chars()
.mapWindows(2, identity)
.enumerate()
.peekable();
while (iter.moveNext()) {
final (index, window) = iter.current;
switch (window) {
case ["!", "?"]:
break;
case ["!", _]:
answer.push(index);
case [_, "!"] when iter.peek() == null: // or `iter.peekOpt().isNone()`
answer.push(index + 1);
}
}
print(answer); // [2, 7]
}
```
## Project Goals
rust's primary goal is to give Dart developers access to powerful tools previously only available to Rust developers.
To accomplish this, Rust's functionalities are carefully adapted to Dart's paradigms, focusing on a smooth idiomatic language-compatible integration.
The result is developers now have a whole new toolset to tackle problems in Dart.
True to the Rust philosophy, rust strives to bring reliability and performance in every feature. Every feature is robustly tested. Over 500 meaningful test suites and counting.