zero_mut 0.1.1 copy "zero_mut: ^0.1.1" to clipboard
zero_mut: ^0.1.1 copied to clipboard

Zero-overhead compile-time immutable collections and zero-copy slicing for Dart using extension types and Never constraints.

example/example.dart

import 'dart:typed_data';
import 'package:zero_mut/zero_mut.dart';

void main() {
  // 1. Core collections & zero-copy slicing
  final list = [10, 20, 30, 40, 50];
  final slice = list.slice(1, 4); // [20, 30, 40]
  print('Slice: ${slice.toListString()}');

  final immMap = {'name': 'zero_mut', 'version': '0.1.0'}.asImm();
  print('Map name: ${immMap['name']}');

  // 2. Low-level zero-copy binary data
  final bytes = Uint8List.fromList([0x12, 0x34, 0x56, 0x78]);
  final byteSlice = bytes.byteSlice(0, 4);
  print('Uint32: 0x${byteSlice.getUint32(0, Endian.big).toRadixString(16)}');

  // 3. Lazy sequences
  final mapped = list.mapLazy((x) => 'item_$x');
  print('Mapped at 0: ${mapped[0]}');

  // 4. Reactive state notifier
  final notifier = ZeroStateNotifier<int>(42);
  final readOnly = notifier.asReadOnly;
  print('Reactive state: ${readOnly.value}');

  // 5. 2D Matrix over flat memory
  final flat = [1, 2, 3, 4, 5, 6];
  final matrix = ZeroMatrix<int>(flat, 2, 3);
  print('Matrix cell (1, 2): ${matrix.get(1, 2)}');
}
1
likes
160
points
103
downloads

Documentation

API reference

Publisher

verified publisherjosephinoo.dev

Weekly Downloads

Zero-overhead compile-time immutable collections and zero-copy slicing for Dart using extension types and Never constraints.

Homepage
Repository (GitHub)
View/report issues

Topics

#collections #immutability #performance #data-structures #memory

License

MIT (license)

More

Packages that depend on zero_mut