ruqe 1.0.0 ruqe: ^1.0.0 copied to clipboard
Ruqe brings the convenient types and methods found in Rust into Dart, such as the Result, Option, pattern-matching, etc.
ruqe #
Ruqe brings the convenient types and methods found in Rust into Dart, such as
the Result
, Option
, pattern-matching
, etc. Additionally, the library provides
an excellent concept for modeling errors without resorting to exceptions
.
Getting started #
In your Dart/Flutter project, add the dependency to your pubspec.yaml
dependencies:
ruqe: ^1.0.0
import with
import 'package:ruqe/ruqe.dart';
Basic usage #
We can use Result as shown below:
void main() {
var trigger = triggerError();
var result = trigger.match<int?>(
ok: (value) => value,
err: (_) => 0,
);
print(result);
}
Result<int, String> triggerError() {
try {
var value = int.parse("%65");
return Ok(value);
} catch (err) {
return Err("Value is none");
}
}