Skip to content

Commit

Permalink
chore: Lints
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmah309 committed Dec 8, 2023
1 parent c3da133 commit 42e297f
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 51 deletions.
19 changes: 10 additions & 9 deletions example/main.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import 'package:rust_core/core.dart'; // Or import 'package:rust_core/<LIBRARY_NAME>.dart';

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

Result<int,String> usingTheEarlyReturnKey() => Result(($){ // Early Return Key
// Will return here with 'Err("error")'
int x = willAlwaysReturnErr()[$].toInt();
return Ok(x);
});
Result<int, String> usingTheEarlyReturnKey() => Result(($) {
// Early Return Key
// Will return here with 'Err("error")'
int x = willAlwaysReturnErr()[$].toInt();
return Ok(x);
});

Result<int,String> usingRegularPatternMatching(){
Result<int, String> usingRegularPatternMatching() {
int x;
switch(willAlwaysReturnErr()){
switch (willAlwaysReturnErr()) {
case Err(:final err):
return Err(err);
case Ok(:final ok):
Expand All @@ -22,4 +23,4 @@ Result<int,String> usingRegularPatternMatching(){
return Ok(x);
}

Result<double,String> willAlwaysReturnErr() => Err("error");
Result<double, String> willAlwaysReturnErr() => Err("error");
12 changes: 6 additions & 6 deletions lib/src/cell/cell/cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,40 @@ part 'double_cell.dart';
class Cell<T> {
T _val;

Cell(T val): _val = val;
Cell(T val) : _val = val;

/// Returns the inner value.
T get() {
return _val;
}

/// Replaces the inner value with the provided [val] and returns the original inner value.
T replace(T val){
T replace(T val) {
final temp = _val;
_val = val;
return temp;
}

/// Sets the inner value to [val].
void set(T val){
void set(T val) {
_val = val;
}

/// swaps the inner values between this cell and that [cell].
void swap(covariant Cell<T> cell){
void swap(covariant Cell<T> cell) {
final temp = cell._val;
cell._val = _val;
_val = temp;
}

/// Updates the contained value using [fn] and returns the new value
T update(T Function(T) fn){
T update(T Function(T) fn) {
_val = fn(_val);
return _val;
}

/// Shallow copy of this [Cell].
Cell<T> copy(){
Cell<T> copy() {
return Cell(_val);
}

Expand Down
5 changes: 2 additions & 3 deletions lib/src/cell/lazy_cell/const_non_nullable_lazy_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class ConstNonNullableLazyCell<T extends Object> implements LazyCell<T> {

@override
bool operator ==(Object other) {
return other is ConstNonNullableLazyCell &&
_cache[this] == _cache[other];
return other is ConstNonNullableLazyCell && _cache[this] == _cache[other];
}

@override
Expand All @@ -48,4 +47,4 @@ class ConstNonNullableLazyCell<T extends Object> implements LazyCell<T> {
}
return initializedState + runtimeType.toString();
}
}
}
5 changes: 2 additions & 3 deletions lib/src/cell/lazy_cell/const_nullable_lazy_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class ConstNullableLazyCell<T> implements NullableLazyCell<T> {

@override
bool operator ==(Object other) {
return other is ConstNullableLazyCell &&
_cache[this] == _cache[other];
return other is ConstNullableLazyCell && _cache[this] == _cache[other];
}

@override
Expand All @@ -47,4 +46,4 @@ class ConstNullableLazyCell<T> implements NullableLazyCell<T> {
}
return initializedState + runtimeType.toString();
}
}
}
5 changes: 3 additions & 2 deletions lib/src/cell/lazy_cell/lazy_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ abstract interface class LazyCell<T extends Object>
implements NullableLazyCell<T> {
factory LazyCell(T Function() func) = NonNullableLazyCell;

const factory LazyCell.constant(T Function() func, Object id) = ConstNonNullableLazyCell;
}
const factory LazyCell.constant(T Function() func, Object id) =
ConstNonNullableLazyCell;
}
4 changes: 1 addition & 3 deletions lib/src/cell/lazy_cell/non_nullable_lazy_cell.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:rust_core/cell.dart';


/// A value which is initialized on the first access. Non-nullable implementation of [LazyCell]
///
/// Equality: Cells are equal if they are [NonNullableLazyCell] and have the same evaluated value or are unevaluated.
Expand Down Expand Up @@ -29,8 +28,7 @@ class NonNullableLazyCell<T extends Object> implements LazyCell<T> {

@override
bool operator ==(Object other) {
return other is NonNullableLazyCell &&
_val == other._val;
return other is NonNullableLazyCell && _val == other._val;
}

@override
Expand Down
3 changes: 1 addition & 2 deletions lib/src/cell/lazy_cell/nullable_lazy_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class NullableLazyCell<T> {

@override
bool operator ==(Object other) {
return other is NullableLazyCell &&
_val == other._val;
return other is NullableLazyCell && _val == other._val;
}

@override
Expand Down
5 changes: 2 additions & 3 deletions lib/src/cell/once_cell/const_non_nullable_once_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ class ConstNonNullableOnceCell<T extends Object> implements OnceCell<T> {

@override
bool operator ==(Object other) {
return other is ConstNonNullableOnceCell &&
_cache[this] == _cache[other];
return other is ConstNonNullableOnceCell && _cache[this] == _cache[other];
}

@override
Expand All @@ -113,4 +112,4 @@ class ConstNonNullableOnceCell<T extends Object> implements OnceCell<T> {
}
return initializedState + runtimeType.toString();
}
}
}
5 changes: 2 additions & 3 deletions lib/src/cell/once_cell/const_nullable_once_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class ConstNullableOnceCell<T> implements NullableOnceCell<T> {

@override
bool operator ==(Object other) {
return other is ConstNullableOnceCell &&
_cache[this] == _cache[other];
return other is ConstNullableOnceCell && _cache[this] == _cache[other];
}

@override
Expand All @@ -93,4 +92,4 @@ class ConstNullableOnceCell<T> implements NullableOnceCell<T> {
}
return initializedState + runtimeType.toString();
}
}
}
5 changes: 2 additions & 3 deletions lib/src/cell/once_cell/non_nullable_once_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,12 @@ class NonNullableOnceCell<T extends Object> implements OnceCell<T> {

@override
bool operator ==(Object other) {
return other is NonNullableOnceCell &&
_val == other._val;
return other is NonNullableOnceCell && _val == other._val;
}

@override
String toString() {
return (_val == null ? "Uninitialized " : "Initialized ") +
runtimeType.toString();
}
}
}
5 changes: 2 additions & 3 deletions lib/src/cell/once_cell/nullable_once_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,12 @@ class NullableOnceCell<T> {

@override
bool operator ==(Object other) {
return other is NullableOnceCell &&
_val == other._val;
return other is NullableOnceCell && _val == other._val;
}

@override
String toString() {
return (_isSet ? "Initialized " : "Uninitialized ") +
runtimeType.toString();
}
}
}
1 change: 0 additions & 1 deletion lib/src/cell/once_cell/once_cell.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:rust_core/cell.dart';


/// OnceCell, A cell which can be written to only once.
///
/// Equality: Cells are equal if they have the same value and have the same base cell type.
Expand Down
1 change: 0 additions & 1 deletion lib/src/option/future_option.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';

import 'package:rust_core/option.dart';
import 'package:rust_core/result.dart';

/// {@macro futureOption}
typedef FutureOption<T extends Object> = Future<Option<T>>;
Expand Down
1 change: 0 additions & 1 deletion lib/src/option/future_result_and_option_extensions.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:rust_core/option.dart';
import 'package:rust_core/result.dart';

extension FutureOptionOnResultExtension<S extends Object, F extends Object>
on FutureResult<S, F> {
Expand Down
1 change: 0 additions & 1 deletion lib/src/option/result_and_option_extensions.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:rust_core/option.dart';
import 'package:rust_core/result.dart';

extension OptionOnResultExtension<S extends Object, F extends Object>
on Result<S, F> {
Expand Down
1 change: 0 additions & 1 deletion test/cell/once_cell_base_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:rust_core/cell.dart';
import 'package:rust_core/result.dart';
import 'package:test/test.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions test/cell/once_cell_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'package:rust_core/cell.dart';
import 'package:rust_core/option.dart';
import 'package:rust_core/result.dart';
import 'package:test/test.dart';

void main() {
Expand Down
1 change: 0 additions & 1 deletion test/option/future_result_and_option_extension_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:rust_core/option.dart';
import 'package:rust_core/result.dart';
import 'package:test/test.dart';

void main() {
Expand Down
1 change: 0 additions & 1 deletion test/option/option_future_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:rust_core/option.dart';
import 'package:rust_core/result.dart';
import 'package:test/test.dart';

void main() {
Expand Down
1 change: 0 additions & 1 deletion test/option/option_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:rust_core/option.dart';
import 'package:rust_core/result.dart';
import 'package:test/test.dart';

void main() {
Expand Down
1 change: 0 additions & 1 deletion test/option/result_and_option_extension_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:rust_core/option.dart';
import 'package:rust_core/result.dart';
import 'package:test/test.dart';

void main() {
Expand Down

0 comments on commit 42e297f

Please sign in to comment.