File tree Expand file tree Collapse file tree 2 files changed +4
-17
lines changed Expand file tree Collapse file tree 2 files changed +4
-17
lines changed Original file line number Diff line number Diff line change 22
33public struct MustSet < T >
44{
5- private bool _set ;
5+ private readonly bool _set ;
66
77 public T Value
88 {
@@ -12,13 +12,13 @@ public T Value
1212 throw new InvalidOperationException ( $ "Attempted to get { typeof ( T ) . Name } before it was set.") ;
1313 return field ;
1414 }
15- set
15+ init
1616 {
1717 field = value ;
1818 _set = true ;
1919 }
2020 }
2121
2222 public static implicit operator T ( MustSet < T > wrapper ) => wrapper . Value ;
23- public static implicit operator MustSet < T > ( T value ) => new MustSet < T > { Value = value } ;
23+ public static implicit operator MustSet < T > ( T value ) => new ( ) { Value = value } ;
2424}
Original file line number Diff line number Diff line change @@ -4,20 +4,7 @@ namespace SER.Helpers.ResultSystem;
44
55public abstract class DynamicTryGet
66{
7- private readonly bool _isStaticSet = false ;
8- public bool IsStatic
9- {
10- get
11- {
12- if ( ! _isStaticSet ) throw new AndrzejFuckedUpException ( "IsStatic cannot be accessed before it is set." ) ;
13- return field ;
14- }
15- protected init
16- {
17- _isStaticSet = true ;
18- field = value ;
19- }
20- }
7+ public MustSet < bool > IsStatic { get ; protected init ; }
218
229 public abstract Result Result { get ; }
2310
You can’t perform that action at this time.
0 commit comments