refactor: Add 'implicit operator T(Optional<T>)' for convenience
This commit is contained in:
1 parent
82ac189ac9
commit
ac8147cc0f
3 files changed
+5
-2
No files matched your search
@@ -189,6 +189,6 @@ namespace mbts {
|
||||
exchange ?? sec_exp.exchange, security_type ?? sec_exp.security_type,
|
||||
symbol ?? sec_exp.symbol,
|
||||
expiration ?? sec_exp.expiration,
|
||||
id.has_value ? id.value : sec_exp.id);
|
||||
id.has_value ? id : sec_exp.id);
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ namespace mbts.spark {
|
||||
new(
|
||||
security ?? trade_info.security,
|
||||
trade ?? trade_info.trade,
|
||||
greeks_tuple.has_value ? greeks_tuple.value : trade_info.greeks_tuple,
|
||||
greeks_tuple.value_or(trade_info.greeks_tuple),
|
||||
volume ?? trade_info.volume);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,9 @@ namespace bts.utils {
|
||||
public static implicit operator Optional<T>(T value) =>
|
||||
new(value);
|
||||
|
||||
public static implicit operator T(Optional<T> optional) =>
|
||||
optional.value;
|
||||
|
||||
public static bool operator ==(Optional<T> left, Optional<T> right) => left.Equals(right);
|
||||
public static bool operator !=(Optional<T> left, Optional<T> right) => !(left == right);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user