Skip to content

Releases: mcmah309/rust

v0.5.3

15 Mar 18:48
Compare
Choose a tag to compare

Full Changelog: v0.5.2...v0.5.3

v0.5.2

15 Mar 13:03
Compare
Choose a tag to compare

Full Changelog: v0.5.1...v0.5.2

v0.5.1

12 Mar 11:12
Compare
Choose a tag to compare

Full Changelog: v0.5.0...v0.5.1

v0.5.0

10 Mar 18:44
Compare
Choose a tag to compare
  • Breaking: Change None() to None
  • Breaking: Migrate RIterator to an Iterable Iterator union
  • Add Array type
  • Implement all of Iter
  • Implement most of Slice
  • More extensions
  • Add prelude library

Full Changelog: v0.4.0...v0.5.0

v0.4.0

03 Mar 00:50
Compare
Choose a tag to compare

Option

A lot of possibilities opened up with Dart 3.3.0 release. Zero cost abstraction with extension types is a powerful tool. Thus, we migrated
the Option class to an extension type. Since exclusive nullable type extensions are not possible, Option fills this gap
with zero allocation runtime cost and chaining null aware operations.

    Option<int> intOptionFunc() => const None();
    double halfVal(int val) => val/2;
    Option<double> val = intOptionFunc().map(halfVal);
    expect(val.unwrapOr(2.0), 2.0);

Considering Option also supports early return key notation.

    Option<int> intNone() => const None();
    Option<double> earlyReturn(int val) => Option(($) { // Early Return Key
    // Returns here, no need to do a `if null return`
    double x = intNone()[$].toDouble();
    return Some(val + x);
    });
    expect(earlyReturn(2), const None());

And transitioning between is ergonomic

    Option<int> option = intNone();
    int? nullable = option.v;
    nullable = option.toNullable(); // or
    option = nullable.toOption();

Option seems like the go to when compared to using nullable directly when developing api's or a least a solid companion.

Slice and Iter

Included in 0.4 are two new libraries slice and iter being developed but with the usual full test coverage guarantee of rust_core.

A Slice is a contiguous sequence of elements in a [List]. Slices are a view into a list without allocating and copying to a new list,
thus slices are more efficient than creating a sublist, but they do not own their own data. That means shrinking the original list can cause the slice's range to become invalid, which may cause an exception.

Slice also have a lot of efficient methods for in-place mutation within and between slices. e.g.

    var list = [1, 2, 3, 4, 5];
    var slice = Slice(list, 1, 4);
    expect(slice, [2, 3, 4]);
    var taken = slice.takeLast();
    expect(taken, 4);
    expect(slice, [2, 3]);
    slice[1] = 10;
    expect(list, [1, 2, 10, 4, 5]);

A Dart Iterable is analogous to a Rust Iterator. Since Dart already has an Iterator class, to avoid confusion,
the Dart implementation of the Rust iterator is RIterator. RIterator is a zero cost extension type of Iterable. RIterator
makes working with collections of rust_core types and regular Dart types a breeze. e.g.

    var list = [1, 2, 3, 4, 5];
    var filtered = list.iter().filterMap((e) {
      if (e % 2 == 0) {
        return Some(e * 2);
      }
      return None();
    });
    expect(filtered, [4, 8]);

Misc

Various additional extension methods were added.

Full Changelog: v0.3.6...v0.4.0

v0.3.6

29 Jan 08:00
43d692a
Compare
Choose a tag to compare

What's Changed

  • Asynchronous version of the Early Return Operator by @cardosoOReis in #2

New Contributors

  • @cardosoOReis made their first contribution in #2

Full Changelog: v0.3.5...v0.3.6

v0.3.5

11 Dec 06:26
Compare
Choose a tag to compare
chore: Bump

v0.3.4

08 Dec 20:14
Compare
Choose a tag to compare
chore: Bump

v0.3.1

07 Dec 21:48
Compare
Choose a tag to compare
chore: Bump

v0.3.0

03 Dec 12:14
Compare
Choose a tag to compare
chore: Bump 0.3.0