rust_core 0.5.0-dev4 copy "rust_core: ^0.5.0-dev4" to clipboard
rust_core: ^0.5.0-dev4 copied to clipboard

Implementation of Rust's core library in Dart. Types like Result, Option, Cells, Slices, Array, Iterators, and extensions. Facilitates functional programming or OOP, and error handling.

example/main.dart

import 'package:rust_core/result.dart';

void main() {
  usingTheEarlyReturnKey();
  usingRegularPatternMatching();
}

Result<int, String> usingTheEarlyReturnKey() => Result(($) {
      // Early Return Key
      // Will return here with 'Err("error")'
      int x = willAlwaysReturnErr()[$].toInt();
      return Ok(x);
    });

Result<int, String> usingRegularPatternMatching() {
  int x;
  switch (willAlwaysReturnErr()) {
    case Err(:final err):
      return Err(err);
    case Ok(:final ok):
      x = ok.toInt();
  }
  return Ok(x);
}

Result<double, String> willAlwaysReturnErr() => Err("error");
25
likes
0
pub points
70%
popularity

Publisher

verified publishervoyver.com

Implementation of Rust's core library in Dart. Types like Result, Option, Cells, Slices, Array, Iterators, and extensions. Facilitates functional programming or OOP, and error handling.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on rust_core