Initial commit
This commit is contained in:
13
lua/cave/option.lua
Normal file
13
lua/cave/option.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
---@class cave.Option
|
||||
local Option
|
||||
|
||||
---@generic ValueType, ResultType
|
||||
---@param opt ValueType?
|
||||
---@param fn fun(opt: ValueType): ResultType
|
||||
---@return ResultType?
|
||||
function Option.map(opt, fn)
|
||||
if opt == nil then return nil end
|
||||
return fn(opt)
|
||||
end
|
||||
|
||||
return Option
|
||||
Reference in New Issue
Block a user