soeur/phpoar

该包的最新版本(dev-master)没有可用的许可信息。

模仿rust的选项和结果。

dev-master 2020-04-18 08:44 UTC

This package is auto-updated.

Last update: 2024-09-20 15:57:22 UTC


README

模仿rust的选项和结果。

使用方法

function test1(\Phpoar\Option $opt) {}
function test2(\Phpoar\Result $result) {}

test1(\Phpoar\Some(1));
test1(\Phpoar\None());
test2(\Phpoar\Ok("ok"));
test2(\Phpoar\Err(new \Exception()));

可用

结果

  • unwrap
  • is_ok
  • is_err
  • ok
  • err
  • map
  • map_or
  • map_or_else
  • map_err
  • and
  • and_then
  • or
  • or_else
  • unwrap_or
  • unwrap_or_else

Option

  • unwrap
  • is_some
  • is_none
  • map
  • unwrap_or
  • unwrap_or_else