Skip to main content

Result

A Result type for use with Futures, with API designed to support strict typing.

Functions

ok

Result.ok(...U...) → Result<never,U...>

Creates a new Result of the Ok type.

err

Result.err(errValueE) → Result<E,never>

Creates a new Result of the Err type.

isOk

Result:isOk() → boolean

Checks whether the Result is of the Ok type.

isErr

Result:isErr() → boolean

Checks whether the Result is of the Err type.

unwrapOk

Result:unwrapOk() → U...

Unwraps the results of an Ok Result.

DANGER

Make sure you use Result:isOk before using this method.

if result:isOk() then
	local result = result:unwrapOk()
end

unwrapErr

Result:unwrapErr() → E

Unwraps the results of an Err Result.

DANGER

Make sure you use Result:isErr before using this method.

if result:isErr() then
	local err = result:unwrapErr()
end
Show raw api
{
    "functions": [
        {
            "name": "isOk",
            "desc": "Checks whether the Result is of the `Ok` type.\r",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\r\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 40,
                "path": "src/Result.luau"
            }
        },
        {
            "name": "isErr",
            "desc": "Checks whether the Result is of the `Err` type.\r",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean\r\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 47,
                "path": "src/Result.luau"
            }
        },
        {
            "name": "unwrapOk",
            "desc": "Unwraps the results of an `Ok` Result.\n:::danger\nMake sure you use [Result:isOk] before using this method.\n```lua\nif result:isOk() then\n\tlocal result = result:unwrapOk()\nend\n```\n:::\r",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "U...\r\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 64,
                "path": "src/Result.luau"
            }
        },
        {
            "name": "unwrapErr",
            "desc": "Unwraps the results of an `Err` Result.\n:::danger\nMake sure you use [Result:isErr] before using this method.\n```lua\nif result:isErr() then\n\tlocal err = result:unwrapErr()\nend\n```\n:::\r",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "E\r\n"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 81,
                "path": "src/Result.luau"
            }
        },
        {
            "name": "ok",
            "desc": "Creates a new Result of the `Ok` type.\r",
            "params": [
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "U..."
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<never, U...>\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 88,
                "path": "src/Result.luau"
            }
        },
        {
            "name": "err",
            "desc": "Creates a new Result of the `Err` type.\r",
            "params": [
                {
                    "name": "errValue",
                    "desc": "",
                    "lua_type": "E"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<E, never>\r\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 100,
                "path": "src/Result.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Result",
    "desc": "A Result type for use with Futures, with API designed\nto support strict typing.\r",
    "source": {
        "line": 17,
        "path": "src/Result.luau"
    }
}