{"id":16811708,"url":"https://github.com/rzvxa/pike","last_synced_at":"2025-10-06T20:27:11.011Z","repository":{"id":245246182,"uuid":"817938612","full_name":"rzvxa/pike","owner":"rzvxa","description":"☀️|\u003e⛅|\u003e☔","archived":false,"fork":false,"pushed_at":"2024-06-21T00:57:19.000Z","size":42,"stargazers_count":47,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T08:05:31.311Z","etag":null,"topics":["macros","pipe","pipeline","rust","rust-macro"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/pike","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rzvxa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2024-06-20T18:57:48.000Z","updated_at":"2025-03-01T17:10:54.000Z","dependencies_parsed_at":"2024-10-26T21:13:59.824Z","dependency_job_id":"a324d99a-31cc-42d2-88ba-199088acc1a0","html_url":"https://github.com/rzvxa/pike","commit_stats":null,"previous_names":["rzvxa/pike"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzvxa%2Fpike","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzvxa%2Fpike/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzvxa%2Fpike/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzvxa%2Fpike/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rzvxa","download_url":"https://codeload.github.com/rzvxa/pike/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248843819,"owners_count":21170488,"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":["macros","pipe","pipeline","rust","rust-macro"],"created_at":"2024-10-13T10:19:32.366Z","updated_at":"2025-10-06T20:27:05.978Z","avatar_url":"https://github.com/rzvxa.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Pike - PipeLike\n\nPike is a macro collection to pipe your functions calls, like in functional languages such as F#, Elixir and OCamel.\n\n## Examples\n\nThe pipe operator |\u003e allows you to establish \"pipelines\" of functions in a flexible manner.\n\n### TL;DR\n\n```rust\n// takes a string's length, doubles it and converts it back into a string\nlet len = pike! {\n  \"abcd\"\n  |\u003e str::len\n  |\u003e (as u32)\n  |\u003e (times(2))\n  |\u003e \u0026\n  |\u003e u32::to_string\n};\n\n// same as\n\nlet len = times(\"abcd\".len() as u32, 2).to_string();\n```\n\n```rust\nfn times(a: u32, b: u32) -\u003e u32{\n    a * b\n}\n\nfn times2(n: u32) -\u003e u32 {\n    times(n, 2)\n}\n\n// Passes the preceding expression as the only argument of proceding function.\nlet num = pike! {\n  2\n  |\u003e times2\n  |\u003e times2\n};\nassert_eq!(num, 2 * 2 * 2);\n\n// Passes the preceding expression as the first argument of proceding function.\n// by wrapping the function in parentheses we can pass the remanining arguments by partially\n// calling the `times` as `times(?, 2)` and passing 2 as its first argument via the pipeline.\nlet num = pike! {\n  1\n  |\u003e (times(2))\n  |\u003e (times(3))\n};\nassert_eq!(num, 1 * 2 * 3);\n\n// call a method using pipelines\nlet len = pike!(\"abcd\" |\u003e str::len);\nassert_eq!(len, \"abcd\".len());\n\n// Closures can also be pipelined similar to partial functions.\nlet c = pike! {\n  ['a', 'b', 'c', 'd']\n  |\u003e (|it: [char; 4]| it[2])\n};\nassert_eq!(c, 'c');\n\n// Piping through `\u0026` symbol would get a reference to the preceding expression.\nlet it = \"it\";\nlet is_it = |r: \u0026\u0026str| it == *r;\n\nlet is_it = pike! {\n  it\n  |\u003e \u0026\n  |\u003e is_it\n};\nassert_eq!(is_it, true);\n\n\n// There are also special macros for options and results but those already have an ergonomic API for chaining.\n\nlet data = pike_opt!(id |\u003e get_cached |\u003e fetch_local |\u003e fetch_remote);\n// same as get_cached(id).or_else(|| fetch_local(id)).or_else(|| fetch_remote(id));\n\nlet result = pike_res!(\"http://rust-lang.org\" |\u003e download |\u003e parse |\u003e get_links);\n// same as download(\"http://rust-lang.org\").map(parse).map(get_links);\n```\n\n\n## Macros\n\n- `pike!` is the \"standard\" pipe macro\n- `pike_res!` works like `pike!` but takes only functions that return a `Result` (of the\n  same type) and returns early if that result is an Err. Useful for combining multiple IO\n  transformations like opening a file, reading the contents and making an HTTP request.\n- `pike_opt!` works like `pike!` but takes only functions that return an `Option` (of the same type).\n  The pipeline will continue to operate on the initial value as long as `None` is returned from all functions.\n  If a function in the pipeline returns `Some`, the macro will exit early and return that value.\n  This can be useful if you want to try out several functions to see which can make use of that value in a specified order.\n\n## Syntax Features\n\nAny `pike` starts with an expression as initial value and requires you\nto specify a function to transform that initial value.\n```rust\nlet result = pike!(2 |\u003e times2);\n// same as times2(2)\n```\n\nYou can get more fancy with functions, too, if you add parentheses like\nin a normal function call, the passed parameters will be applied to that\nfunction after the transformed value.\n\n```rust\nlet result = pike!(2 |\u003e (times(2)));\n// same as times(2, 2)\n```\n\nYou can pass closures \\o/! A closure must be wrapped in parentheses as well.\n```rust\nlet result = pike! {\n  2\n  |\u003e (times(2))\n  |\u003e (|i: u32| i * 2)\n};\n// same as (|i: u32| i * 2)(time(2, 2))\n```\n\nIf you want a function to be called as a method on the transform value, just pass it as a path.\n\n```rust\nlet result = pike!(\"abcd\" |\u003e str::len);\n// same as \"abcd\".len()\n```\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\nPike is spritual successor to [pipeline.rs](https://github.com/johannhof/pipeline.rs) and derives its license from the said project.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally\nsubmitted for inclusion in the work by you, as defined in the Apache-2.0\nlicense, shall be dual licensed as above, without any additional terms or\nconditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frzvxa%2Fpike","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frzvxa%2Fpike","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frzvxa%2Fpike/lists"}