{"id":23318641,"url":"https://github.com/peelonet/peelo-result","last_synced_at":"2025-04-07T05:19:07.324Z","repository":{"id":80332124,"uuid":"266112972","full_name":"peelonet/peelo-result","owner":"peelonet","description":"C++ implementation of Rust's result type","archived":false,"fork":false,"pushed_at":"2024-11-30T14:14:24.000Z","size":226,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-13T09:32:11.627Z","etag":null,"topics":["cpp-library","header-only","result-type"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peelonet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-22T13:07:30.000Z","updated_at":"2024-11-30T14:14:27.000Z","dependencies_parsed_at":"2024-11-30T15:23:30.385Z","dependency_job_id":"f1fb4dc4-4421-458d-ab90-d60b2303a867","html_url":"https://github.com/peelonet/peelo-result","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peelonet%2Fpeelo-result","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peelonet%2Fpeelo-result/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peelonet%2Fpeelo-result/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peelonet%2Fpeelo-result/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peelonet","download_url":"https://codeload.github.com/peelonet/peelo-result/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595335,"owners_count":20963943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp-library","header-only","result-type"],"created_at":"2024-12-20T17:17:48.847Z","updated_at":"2025-04-07T05:19:07.305Z","avatar_url":"https://github.com/peelonet.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# peelo-result\n\n![Build](https://github.com/peelonet/peelo-result/workflows/Build/badge.svg)\n\nHeader only C++11 implementation of [Rust's Result type].\n\n[Doxygen generated API documentation.][API]\n\n[travis-image]: https://travis-ci.com/peelonet/peelo-result.svg?branch=master\n[travis-url]: https://travis-ci.com/peelonet/peelo-result\n[Rust's Result type]: https://doc.rust-lang.org/std/result/\n[API]: https://peelonet.github.io/peelo-result/index.html\n\n## Usage\n\n`result` class has two static methods that construct `result` instances: `ok`\nand `error`. First one creates an \"OK\" result, which holds some kind of value,\nwhile the second one creates erroneous result which holds some kind of error.\n\nWhether an result contains an value or not can be checked with `has_value`\nmethod of `result` class. If this method returns `true`, then it's value can be\naccessed with the `value`  method, otherwise it's error can be accessed with\nthe `error` method.\n\nNote: Accessing `value` or erronous result leads to undefined behavior and vice\nversa.\n\n### Usage example\n\n```C++\n#include \u003ciostream\u003e\n#include \u003cstring\u003e\n#include \u003cpeelo/result.hpp\u003e\n\nstruct my_error\n{\n  int code;\n  std::string message;\n};\n\nint main()\n{\n  auto ok_result = peelo::result\u003cint, my_error\u003e::ok(15);\n  auto err_result = peelo::result\u003cint, my_error\u003e::error({ 404, \"Not Found\" });\n\n  if (ok_result)\n  {\n    std::cout \u003c\u003c \"OK result: \" \u003c\u003c ok_result.value() \u003c\u003c std::endl;\n  }\n\n  if (!err_result)\n  {\n    std::cout \u003c\u003c \"Error code: \" \u003c\u003c err_result.error().code \u003c\u003c std::endl;\n  }\n\n  return 0;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeelonet%2Fpeelo-result","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeelonet%2Fpeelo-result","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeelonet%2Fpeelo-result/lists"}