Skip to content

Commit

Permalink
Remove redundant methods
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz committed Aug 22, 2019
1 parent c53904e commit 73065be
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 51 deletions.
7 changes: 0 additions & 7 deletions src/Option.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,10 @@ static partial class Option
public static (bool HasValue, T Value) None<T>() => default;

public static (bool HasValue, T Value) From<T>(bool isSome, T value) => isSome ? Some(value) : None<T>();
public static (bool HasValue, T Value) From<T>((bool, T) option) => option.ToOption();

public static (bool HasValue, T Value) ToOption<T>(this (bool HasValue, T Value) option) =>
option.HasValue ? Some(option.Value) : None<T>();

public static (bool HasValue, T Value) ToOption<T>(this T? value) where T : struct =>
value is T x ? Some(x) : None<T>();

public static (bool HasValue, T Value) Flagged<T>(this (bool HasValue, T Value) option) =>
option.IsSome() ? (true, option.Value) : default;

public static bool IsSome<T>(this (bool HasValue, T Value) option) => option.HasValue;
public static bool IsNone<T>(this (bool HasValue, T Value) option) => !option.HasValue;

Expand Down
44 changes: 0 additions & 44 deletions tests/OptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,6 @@ public void NoneIsNotSome()
Assert.That(result.IsSome(), Is.False);
}

[Test]
public void ToOptionWithTupleIsSome()
{
var result = (true, 42).ToOption();
Assert.That(result, Is.EqualTo(Option.Some(42)));
}

[Test]
public void ToOptionWithTupleIsNone()
{
var result = (false, 42).ToOption();
Assert.That(result, Is.EqualTo(Option.None<int>()));
}

[Test]
public void ToOptionWithNullableNonNull()
{
Expand All @@ -97,20 +83,6 @@ public void ToOptionWithNullableNull()
Assert.That(result, Is.EqualTo(Option.None<int>()));
}

[Test]
public void FromTuple()
{
var result = Option.From((true, 42));
Assert.That(result, Is.EqualTo(Option.Some(42)));
}

[Test]
public void FromTupleNone()
{
var result = Option.From((false, 42));
Assert.That(result, Is.EqualTo(Option.None<int>()));
}

[Test]
public void From()
{
Expand All @@ -125,22 +97,6 @@ public void FromNone()
Assert.That(result, Is.EqualTo(Option.None<int>()));
}

[Test]
public void Flagged()
{
var (some, x) = Option.Some(42).Flagged();
Assert.That(some, Is.True);
Assert.That(x, Is.EqualTo(42));
}

[Test]
public void FlaggedNone()
{
var (some, x) = Option.None<int>().Flagged();
Assert.That(some, Is.False);
Assert.That(x, Is.Zero);
}

[Test]
public void SomeWhenWithNullPredicate()
{
Expand Down

0 comments on commit 73065be

Please sign in to comment.