rust_core 0.2.1 copy "rust_core: ^0.2.1" to clipboard
rust_core: ^0.2.1 copied to clipboard

Implementation of Rust's core library in a Dart friendly way. Usable by itself, but also a base for libraries that want to build on Rust Semantics.

example/main.dart

import 'package:rust_core/core.dart'; // Or import 'package:rust_core/<LIBRARY_NAME>.dart';

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

Result<int, String> usingTheEarlyReturnKey() => Result.$(($) {
      double x = willAlwaysReturnErr()[$];
      return Ok(x.toInt());
    });

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

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

Publisher

verified publishervoyver.com

Implementation of Rust's core library in a Dart friendly way. Usable by itself, but also a base for libraries that want to build on Rust Semantics.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on rust_core