ruqe 1.2.1 copy "ruqe: ^1.2.1" to clipboard
ruqe: ^1.2.1 copied to clipboard

Ruqe brings the convenient types and methods found in Rust into Dart, such as the Result, Option, pattern-matching, etc.

example/ruqe_example.dart

import 'package:ruqe/ruqe.dart';
import 'package:ruqe/src/shared/core/panic.dart';

void main() {
  /// Calling [stringToNum] with an alphanumeric
  /// data will trigger an exception.
  var trigger = stringToNum("%65");

  /// With pattern matching, we were able to recover from the
  /// exception thrown from calling [int.parse()] and return
  /// 0 instead.
  var result = trigger.match<int?>(
    ok: (value) => value,
    err: (_) => 0,
  );

  print("Result: $result"); // Result: 0
}

Result<int, String> stringToNum(String str) {
  try {
    var value = int.parse(str);
    return Ok(value);
  } catch (err) {
    return Err("Value is none");
  }
}
6
likes
0
pub points
18%
popularity

Publisher

unverified uploader

Ruqe brings the convenient types and methods found in Rust into Dart, such as the Result, Option, pattern-matching, etc.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

equatable

More

Packages that depend on ruqe