Skip to content

Commit

Permalink
Cleaned up some dumb local libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Aug 5, 2023
1 parent b960790 commit 896e6e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
18 changes: 6 additions & 12 deletions Schema/src/util/Asserts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,15 @@ public static bool Equal(
string? message = null)
=> Equal<string>(expected, actual, message);

public static bool IsA<TExpected>(object? instance, string? message = null)
=> IsA(instance, typeof(TExpected), message);

public static bool IsA(
object? instance,
Type expected,
string? message = null)
=> Nonnull(instance, message) &&
Equal(instance!.GetType(), expected, message);

public static TExpected AsA<TExpected>(
object? instance,
string? message = null) {
IsA<TExpected>(instance, message);
return (TExpected) instance!;
if (instance is TExpected expected) {
return expected;
}

Asserts.Fail(message);
return default!;
}

public static T Assert<T>(T? value) where T : notnull {
Expand Down
4 changes: 4 additions & 0 deletions Schema/src/util/enumerables/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace schema.util.enumerables {
public static class EnumerableExtensions {
public static IEnumerable<T> Yield<T>(this T value) {
yield return value;
}

public static IEnumerable<T> Resized<T>(
this IEnumerable<T>? enumerable,
int length) where T : new() {
Expand Down

0 comments on commit 896e6e3

Please sign in to comment.