{"id":25827049,"url":"https://github.com/guangie88/rustfp","last_synced_at":"2025-02-28T15:52:21.483Z","repository":{"id":43414990,"uuid":"88762706","full_name":"guangie88/rustfp","owner":"guangie88","description":"C++ implementation of Rust Option/Result and Iterator.","archived":false,"fork":false,"pushed_at":"2022-03-02T13:18:55.000Z","size":339,"stargazers_count":12,"open_issues_count":7,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-11T16:08:16.269Z","etag":null,"topics":["cpp","cpp14","functional-programming","iterator","monad","monadic","monadic-optionals","monadic-result","rust"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guangie88.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-19T15:46:42.000Z","updated_at":"2022-11-29T09:19:05.000Z","dependencies_parsed_at":"2022-09-12T09:50:30.207Z","dependency_job_id":null,"html_url":"https://github.com/guangie88/rustfp","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guangie88%2Frustfp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guangie88%2Frustfp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guangie88%2Frustfp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guangie88%2Frustfp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guangie88","download_url":"https://codeload.github.com/guangie88/rustfp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241176625,"owners_count":19922732,"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","cpp14","functional-programming","iterator","monad","monadic","monadic-optionals","monadic-result","rust"],"created_at":"2025-02-28T15:52:20.788Z","updated_at":"2025-02-28T15:52:21.465Z","avatar_url":"https://github.com/guangie88.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `rustfp`\n\n[![Build Status](https://travis-ci.org/guangie88/rustfp.svg?branch=master)](https://travis-ci.org/guangie88/rustfp)\n[![Build status](https://ci.appveyor.com/api/projects/status/gx7vmcs5vlar60m6/branch/master?svg=true)](https://ci.appveyor.com/project/guangie88/rustfp/branch/master)\n[![codecov](https://codecov.io/gh/guangie88/rustfp/branch/master/graph/badge.svg)](https://codecov.io/gh/guangie88/rustfp)\n\n## Overview\n\nC++14 implementation of Rust Option/Result (monads) and Iterator concepts,\nuseful for expressing items and result manipulation in a more functional style.\n\n* [https://doc.rust-lang.org/std/option/](https://doc.rust-lang.org/std/option/)\n* [https://doc.rust-lang.org/std/result/](https://doc.rust-lang.org/std/result/)\n* [https://doc.rust-lang.org/std/iter/](https://doc.rust-lang.org/std/iter/)\n\nCurrently tested to be compiling on `g++-5` and above, `MSVC2015` and above.\n`clang` should work as well, as long as the version supports C++14.\n\n## Repository Checkout\n\nFor Git version 1.6.5 or later:\n\n```bash\ngit clone --recursive https://github.com/guangie88/rustfp.git\n```\n\nFor already cloned repository or older Git version:\n\n```bash\ngit clone https://github.com/guangie88/rustfp.git\ngit submodule update --init --recursive\n```\n\n## Compilation and Installation\n\nThe solution uses CMake (at least version 3.6) for compilation and installation.\nTo enable unit tests to be compiled for `rustfp`, add\n`-DRUSTFP_INCLUDE_UNIT_TESTS=ON` during the CMake configuration step.\n\n### Windows Generator Names\n\n* MSVC\n\n  * 32-bit\n    * `MSVC2015`: `Visual Studio 14`\n    * `MSVC2017`: `Visual Studio 15`\n  * 64-bit\n\n    * `MSVC2015`: `Visual Studio 14 Win64`\n    * `MSVC2017`: `Visual Studio 15 Win64`\n\n### Windows Compilation\n\n#### Debug and Release Compilation Example\n\n```bash\nmkdir build\ncd build\ncmake .. -G \"Visual Studio 14 Win64\" -DCMAKE_INSTALL_PREFIX:PATH=install\ncmake --build . --config debug\ncmake --build . --config release --target install\n```\n\n### Linux Generator Names\n\nFor Linux, simply run\n`export CC=\u003cpath-to-desired-CC-compiler\u003e; export CXX=\u003cpath-to-desired-CXX-compiler\u003e`\nbefore running the CMake commands. As such, there should be no need to set\n`-G \u003cgenerator-name\u003e`.\n\n#### Example\n\n```bash\nexport CC=/usr/bin/gcc-5; export CXX=/usr/bin/g++-5\n```\n\n### Linux Compilation\n\nNote that `gcc` requires the build type to be specified at the CMake\nconfiguration step.\n\n#### Debug Compilation Example\n\n```bash\nmkdir build-debug\ncd build-debug\ncmake .. -DCMAKE_BUILD_TYPE=Debug\ncmake --build .\n```\n\n#### Release Compilation Example\n\n```bash\nmkdir build-release\ncd build-release\ncmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=install\ncmake --build . --target install\n```\n\n### Installation Extraction\n\nFor the header files that are required to be included in other solutions, simply\nextract out the following directories in `build/install/include` into your other\ndesired `include` directory:\n\n* `nonstd`\n* `mpark`\n* `rustfp`\n\n## Usage Examples\n\n```c++\n#include \"rustfp/collect.h\"\n#include \"rustfp/iter.h\"\n#include \"rustfp/map.h\"\n\n#include \u003ccassert\u003e\n#include \u003cstring\u003e\n#include \u003cvector\u003e\n\nint main() {\n    const std::vector\u003cint\u003e v_int{0, 1, 2};\n\n    // rustfp::iter works differently from C++ iterator.\n    // containers with proper begin/cbegin and end/cend\n    // has to be wrapped by rustfp::iter before any of\n    // the FP operations (e.g. map, filter, fold) can be\n    // used.\n\n    const auto v_str = rustfp::iter(v_int)\n        | rustfp::map([](const auto \u0026v) {\n            // v is of const int \u0026 type\n            return std::to_string(v);\n        })\n        | rustfp::collect\u003cstd::vector\u003cstd::string\u003e\u003e();\n\n    assert(v_str[0] == \"0\");\n    assert(v_str[1] == \"1\");\n    assert(v_str[2] == \"2\");\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguangie88%2Frustfp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguangie88%2Frustfp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguangie88%2Frustfp/lists"}