Skip to content

Releases: mcmah309/rust

v3.1.0

23 Dec 01:15
Compare
Choose a tag to compare

v3.0.0

12 Dec 22:17
Compare
Choose a tag to compare
  • Breaking: New sealed type Option implementation
    • Using Option as an extension type proved not to be very useful in practice. In fact, Option as a
      sealed type would be more useful for a few reason outlined in the updated option docs
  • Breaking: Nullable methods added for every Option method and vice versa
    • Going back to our roots, we now equally support nullable and option methods going forward. Nullable methods are the default. e.g. peek() now returns a T?, peekOpt() returns Option<T>.
  • Breaking: Rename okay/o and e/error on Result to v.
    • In preparation for the @Enum macro, we standardized the naming for enum/sealed types with one value - v for one. And v1, v2, ... for many (if unnamed) when the macro is released. A concise name is optimal for renaming e.g Ok(v:final order) or Err(v:final error)
  • Add Fs library
  • Add Env library
  • Misc additions
  • Rename/refactor

Full Changelog: v2.0.0...v3.0.0

v2.0.0

02 Dec 13:48
Compare
Choose a tag to compare

rust_core Renamed to rust

Changes

  • Add Path, UnixPath, WindowsPath
  • Add KeyedMutex
  • Add o/okay to Ok, e/error to Err, value to Option
  • Change channel to localChannel
  • Remove deprecations
  • Remove individual library import files
  • Rename extensions
  • Rename errors

Going Forward

With the coming of macro's in Dart. There a lot more possibilities for the package going forward. On the list is

  • Implementing the base rust derive macros such as - #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] in Dart.
  • Early Return Macro
  • Implementing an enum macro to concisely declare and generate rust like enums with sealed types.

Looking forward to the future of Dart!

Full Changelog: v1.3.2...v2.0.0

v1.3.2

30 Sep 22:18
526e37b
Compare
Choose a tag to compare
  • Add v field to FutureOption
  • Add RecordToOption* extensions to Option
  • Add asVec and asList to array

Full Changelog: v1.3.0...v1.3.2

v1.3.0

06 Aug 05:38
Compare
Choose a tag to compare

LazyCellAsync

A value which is asynchronously initialized on the first access.

int callCount = 0;
final lazyCell = LazyCellAsync<int>(() async {
  callCount++;
  return 20;
});
final firstCall = await lazyCell.force();
expect(callCount, equals(1));
expect(firstCall, equals(20));
final secondCall = lazyCell(); // Could also call `await lazyCell.force()` again.
expect(callCount, equals(1));
expect(secondCall, equals(20));

RIterator Renamed to Iter

RIterator was renamed to Iter. RIterator is now a deprecated typedef of Iter (for backwards compatibility).

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

Vec

Vec adds additional extension methods for List and adds a Vec type - a typedef of List.
Vec is used to specifically denote a contiguous growable array,
unlike List which is growable or non-growable, which may cause runtime exceptions. Vec being a typedef of
List means it can be used completely interchangeably.

Vec<int> vec = [1, 2, 3, 4];
// easily translate back and forth
List<int> list = vec;
vec = list;

Vec is a nice compliment to Arr (array) type. Vec is not included in
'package:rust_core/rust_core.dart' instead it is included included in 'package:rust_core/vec.dart'.

Usage

import 'package:rust_core/rust_core.dart';
import 'package:rust_core/vec.dart';

void main() {
  Vec<int> vec = [1, 2, 3, 4];

  Vec<int> replaced = vec.splice(1, 3, [5, 6]);
  print(replaced); // [2, 3]
  print(vec); // [1, 5, 6, 4]

  vec.push(5);
  vec.insert(2, 99);

  int removed = vec.removeAt(1);
  print(removed); // 5
  print(vec); // [1, 99, 6, 4, 5]

  vec.resize(10, 0);
  print(vec); // [1, 99, 6, 4, 5, 0, 0, 0, 0, 0]

  Iter<int> iterator = vec.extractIf((element) => element % 2 == 0);
  Vec<int> extracted = iterator.collectVec();
  print(extracted); // [6, 4, 0, 0, 0, 0, 0]
  print(vec); // [1, 99, 5]

  Slice<int> slice = vec.asSlice();
}

Full Changelog: v1.2.0...v1.3.0

v1.2.0

10 Jul 00:53
Compare
Choose a tag to compare

Slice<T> now implements List<T>

New RangeBounds

RangeBounds works the same as Rust's RangeBounds (usually seen as syntactic sugar e.g. 1..=3)
They have two uses:

  1. RangeBounds can be used to get a Slice of an Arr, Slice, or List.
void func(RangeBounds bounds) {
    Arr<int> arr = Arr.range(0, 10);
    Slice<int> slice = arr(bounds);
    expect(slice, equals([4, 5, 6, 7, 8, 9]));
}

func(RangeFrom(4));

The variants are Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, and RangeToInclusive.

  1. RangeBounds that also implement IterableRangeBounds can be iterated over as a generator.
for(int x in Range(5, 10)){ // 5, 6, 7, 8, 9
    // code
}

All RangeBounds can be const.

v1.1.0

07 Jul 17:15
Compare
Choose a tag to compare

Range

range is a convenience function for a generator over the range [start..end).

for(final x in range(0, 10)){
    // code
}

Note Arr.range(..) was also added as a more efficient method for when it is known collecting the range is needed.

v1.0.0

03 Jul 00:04
Compare
Choose a tag to compare

rust_core v1.0.0 release!🎉

Checkout the new rust_core Book 📖

v0.5.6

28 May 19:33
Compare
Choose a tag to compare
  • Add Unreachable
  • Remove meta dependency

Full Changelog: v0.5.4...v0.5.6

v0.5.4

10 May 22:00
Compare
Choose a tag to compare
  • Add clone method to RIterator classes
  • Add mpsc library with channel function
  • Add sync library with Mutex and RwLock

Full Changelog: v0.5.3...v0.5.4