Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/containers/result.c

    r79308c8e r64fc0ba  
    2121void ?{}(result(T, E) * this) {
    2222        this->has_value = false;
    23         (this->error){};
     23        (&this->error){};
    2424}
    2525
     
    4949void ^?{}(result(T, E) * this) {
    5050        if (this->has_value) {
    51                 ^(this->value){};
     51                ^(&this->value){};
    5252        } else {
    53                 ^(this->error){};
     53                ^(&this->error){};
    5454        }
    5555}
    5656
    5757forall(otype T, otype E)
    58 _Bool ?!=?(result(T, E) this, zero_t) {
    59         return !this->has_value;
     58bool ?!=?(result(T, E) this, zero_t) {
     59        return !this.has_value;
    6060}
    6161
    6262forall(otype T, otype E)
    6363result(T, E) result_value(T value) {
    64         return (Result(T, E)){1, value};
     64        return (result(T, E)){1, value};
    6565}
    6666
    6767forall(otype T, otype E)
    6868result(T, E) result_error(E error) {
    69         return (Result(T, E)){0, value};
     69        return (result(T, E)){0, error};
    7070}
    7171
    7272forall(otype T, otype E)
    73 _Bool has_value(result(T, E) * this) {
     73bool has_value(result(T, E) * this) {
    7474        return this->has_value;
    7575}
     
    7777forall(otype T, otype E)
    7878T 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");
    8080        return this->value;
    8181}
     
    8383forall(otype T, otype E)
    8484E 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");
    8686        return this->error;
    8787}
Note: See TracChangeset for help on using the changeset viewer.