Skip to content

A Result type for java. Inspired by the Rust Result type.

License

Notifications You must be signed in to change notification settings

hdevalke/result4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maintenance

Alternative libraries with ADTs:

result4j

A Result type for java. Inspired by the Rust Result type.

import static result4j.Result.ok;
import static result4j.Result.err;

public class Main {

    public static void main(String... args) {
        Result<Integer, Integer> good = ok(1);
        assert 2 == good.map(i -> i + 1).unwrapOr(0);

        Result<Integer, Integer> bad = err(1);
        assert 0 == bad.map(i -> i + 1).unwrapOr(0);
    }
}

About

A Result type for java. Inspired by the Rust Result type.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages