Releases: mcmah309/rust
v3.1.0
- Add OpenOptions
Full Changelog: v3.0.0...v3.1.0
v3.0.0
- Breaking: New sealed type
Optionimplementation- Using
Optionas an extension type proved not to be very useful in practice. In fact,Optionas a
sealed type would be more useful for a few reason outlined in the updated option docs
- Using
- Breaking: Nullable methods added for every
Optionmethod 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 aT?,peekOpt()returnsOption<T>.
- Going back to our roots, we now equally support nullable and option methods going forward. Nullable methods are the default. e.g.
- Breaking: Rename
okay/oande/erroronResultto v.- In preparation for the
@Enummacro, we standardized the naming for enum/sealed types with one value -vfor one. Andv1,v2, ... for many (if unnamed) when the macro is released. A concise name is optimal for renaming e.gOk(v:final order)orErr(v:final error)
- In preparation for the
- Add Fs library
- Add Env library
- Misc additions
- Rename/refactor
Full Changelog: v2.0.0...v3.0.0
v2.0.0
rust_core Renamed to rust
Changes
- Add
Path,UnixPath,WindowsPath - Add
KeyedMutex - Add
o/okaytoOk,e/errortoErr,valuetoOption - Change
channeltolocalChannel - 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
sealedtypes.
Looking forward to the future of Dart!
Full Changelog: v1.3.2...v2.0.0
v1.3.2
- Add
vfield toFutureOption - Add
RecordToOption*extensions toOption - Add
asVecandasListto array
Full Changelog: v1.3.0...v1.3.2
v1.3.0
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
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:
RangeBoundscan be used to get aSliceof anArr,Slice, orList.
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.
RangeBoundsthat also implementIterableRangeBoundscan 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
v1.0.0
rust_core v1.0.0 release!🎉
Checkout the new rust_core Book 📖
v0.5.6
- Add Unreachable
- Remove meta dependency
Full Changelog: v0.5.4...v0.5.6
v0.5.4
- Add
clonemethod toRIteratorclasses - Add
mpsclibrary withchannelfunction - Add
synclibrary withMutexandRwLock
Full Changelog: v0.5.3...v0.5.4