edit: not that it proves anything, just that "it can eventually be done".
enum ConnState { Disconnected, Connecting, Connected(net::TcpSocket), Transferring(net::TcpSocket), }
import std.typecons; import std.socket; import std.variant; struct Disconnected {} struct Connecting {} alias Connected = Typedef!(TcpSocket, null, "connected"); alias Transferring = Typedef!(TcpSocket, null, "transferring"); alias ConnState = Algebraic!(Disconnected, Connecting, Connected, Transferring);
You can create such new types with std.typecons.Typedef https://dlang.org/phobos/std_typecons.html#.Typedef
Though it's less pretty.
edit: not that it proves anything, just that "it can eventually be done".