0

Is there any simpler way to cast Option<T> to Option<Base type of T> than using Match and casting inside of it?

This is the solution to casting that i am currently using:

private Set<Actor> Actors { get; }

public SelectedData(Option<Actor> actor)
    => Actors = actor.Match(a => Set(a), Set<Actor>());
    
public static SelectedData From<T>(Option<T> actor) where T : Actor
    => new(actor.Match<Option<Actor>>(a => Some(a as Actor), None));
canton7
  • 37,633
  • 3
  • 64
  • 77
Amakazor
  • 29
  • 1
  • 3

0 Answers0