Changes in src/libcfa/containers/result.c [79308c8e:64fc0ba]
- File:
-
- 1 edited
-
src/libcfa/containers/result.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/containers/result.c
r79308c8e r64fc0ba 21 21 void ?{}(result(T, E) * this) { 22 22 this->has_value = false; 23 ( this->error){};23 (&this->error){}; 24 24 } 25 25 … … 49 49 void ^?{}(result(T, E) * this) { 50 50 if (this->has_value) { 51 ^( this->value){};51 ^(&this->value){}; 52 52 } else { 53 ^( this->error){};53 ^(&this->error){}; 54 54 } 55 55 } 56 56 57 57 forall(otype T, otype E) 58 _Bool ?!=?(result(T, E) this, zero_t) {59 return !this ->has_value;58 bool ?!=?(result(T, E) this, zero_t) { 59 return !this.has_value; 60 60 } 61 61 62 62 forall(otype T, otype E) 63 63 result(T, E) result_value(T value) { 64 return ( Result(T, E)){1, value};64 return (result(T, E)){1, value}; 65 65 } 66 66 67 67 forall(otype T, otype E) 68 68 result(T, E) result_error(E error) { 69 return ( Result(T, E)){0, value};69 return (result(T, E)){0, error}; 70 70 } 71 71 72 72 forall(otype T, otype E) 73 _Bool has_value(result(T, E) * this) {73 bool has_value(result(T, E) * this) { 74 74 return this->has_value; 75 75 } … … 77 77 forall(otype T, otype E) 78 78 T get(result(T, E) * this) { 79 assertf(this->has_value, "attempt to get from result without value");79 assertf(this->has_value, "attempt to get from result without value"); 80 80 return this->value; 81 81 } … … 83 83 forall(otype T, otype E) 84 84 E get_error(result(T, E) * this) { 85 assertf(this->has_value, "attempt to get from result without error");85 assertf(this->has_value, "attempt to get from result without error"); 86 86 return this->error; 87 87 }
Note:
See TracChangeset
for help on using the changeset viewer.