{"id":15648947,"url":"https://github.com/ksxgithub/pipe-trait","last_synced_at":"2025-04-05T07:01:46.336Z","repository":{"id":42704424,"uuid":"265826572","full_name":"KSXGitHub/pipe-trait","owner":"KSXGitHub","description":"Make it possible to chain regular functions","archived":false,"fork":false,"pushed_at":"2024-10-29T16:04:29.000Z","size":99,"stargazers_count":46,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T06:04:16.366Z","etag":null,"topics":["crate","functional-programming","no-std","pipe","pipeline","rust","trait"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/pipe-trait","language":"Rust","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/KSXGitHub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"KSXGitHub","patreon":"khai96_","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-05-21T11:04:26.000Z","updated_at":"2025-03-22T11:38:00.000Z","dependencies_parsed_at":"2024-11-15T00:02:48.033Z","dependency_job_id":"49cbb7f6-c2cb-4f79-869c-875b26d3d2b6","html_url":"https://github.com/KSXGitHub/pipe-trait","commit_stats":{"total_commits":118,"total_committers":4,"mean_commits":29.5,"dds":"0.22881355932203384","last_synced_commit":"94c9616a4e54d9eea8482ab1fc665319b4bfe57f"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KSXGitHub%2Fpipe-trait","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KSXGitHub%2Fpipe-trait/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KSXGitHub%2Fpipe-trait/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KSXGitHub%2Fpipe-trait/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KSXGitHub","download_url":"https://codeload.github.com/KSXGitHub/pipe-trait/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299828,"owners_count":20916190,"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":["crate","functional-programming","no-std","pipe","pipeline","rust","trait"],"created_at":"2024-10-03T12:27:11.330Z","updated_at":"2025-04-05T07:01:46.267Z","avatar_url":"https://github.com/KSXGitHub.png","language":"Rust","funding_links":["https://github.com/sponsors/KSXGitHub","https://patreon.com/khai96_"],"categories":[],"sub_categories":[],"readme":"# Pipe Trait\n\n[![Test](https://github.com/KSXGitHub/pipe-trait/workflows/Test/badge.svg)](https://github.com/KSXGitHub/pipe-trait/actions?query=workflow%3ATest)\n[![Crates.io Version](https://img.shields.io/crates/v/pipe-trait?logo=rust)](https://crates.io/crates/pipe-trait)\n\nMake it possible to chain regular functions.\n\n## APIs\n\nBy adding `use pipe_trait::*`, 9 methods are added to all types:\n\n|        identifier       |       pipe syntax      |  traditional syntax |\n|:-----------------------:|:----------------------:|:-------------------:|\n| `Pipe::pipe`            | `x.pipe(f)`            | `f(x)`              |\n| `Pipe::pipe_ref`        | `x.pipe_ref(f)`        | `f(\u0026x)`             |\n| `Pipe::pipe_mut`        | `x.pipe_mut(f)`        | `f(\u0026mut x)`         |\n| `Pipe::pipe_as_ref`     | `x.pipe_as_ref(f)`     | `f(x.as_ref())`     |\n| `Pipe::pipe_as_mut`     | `x.pipe_as_mut(f)`     | `f(x.as_mut())`     |\n| `Pipe::pipe_deref`      | `x.pipe_deref(f)`      | `f(\u0026x)`             |\n| `Pipe::pipe_deref_mut`  | `x.pipe_deref_mut(f)`  | `f(\u0026mut x)`         |\n| `Pipe::pipe_borrow`     | `x.pipe_borrow(f)`     | `f(x.borrow())`     |\n| `Pipe::pipe_borrow_mut` | `x.pipe_borrow_mut(f)` | `f(x.borrow_mut())` |\n\nRead [the docs](https://docs.rs/pipe-trait) for more information.\n\n## Usage Examples\n\n### Same type\n\n```rust\nuse pipe_trait::*;\nlet inc = |x| x + 1;\nlet double = |x| x + x;\nlet square = |x| x * x;\nlet a = (123i32).pipe(inc).pipe(double).pipe(square);\nlet b = square(double(inc(123i32)));\nassert_eq!(a, b);\n```\n\n### Type transformation\n\n```rust\nuse pipe_trait::*;\nlet x = 'x';\nlet a = x\n    .pipe(|x| (x, x, x)) // (char, char, char)\n    .pipe(|x| [x, x]) // [(char, char, char); 2]\n    .pipe(|x| format!(\"{:?}\", x)); // String\nlet b = \"[('x', 'x', 'x'), ('x', 'x', 'x')]\";\nassert_eq!(a, b);\n```\n\n### Pipe amongst method chain\n\n```rust\nuse pipe_trait::*;\nfn log\u003cX: Debug\u003e(x: X) -\u003e X {\n    println!(\"value: {:?}\", x);\n    x\n}\nmy_future\n    .pipe(log)\n    .await\n    .pipe(log)\n    .inc()\n    .pipe(log)\n    .double()\n    .pipe(log)\n    .square()\n    .pipe(log)\n    .get()\n    .pipe(log);\n```\n\n### Explicit type annotation\n\n```rust\nuse pipe_trait::*;\nlet x = \"abc\".to_string();\nlet a = x\n    .pipe_ref::\u003c\u0026str, _\u003e(AsRef::as_ref)\n    .chars()\n    .pipe::\u003cBox\u003c_\u003e, _\u003e(Box::new)\n    .collect::\u003cVec\u003c_\u003e\u003e();\nlet b = vec!['a', 'b', 'c'];\nassert_eq!(a, b);\n```\n\n## License\n\n[MIT](https://git.io/JfgHW) © [Hoàng Văn Khải](https://ksxgithub.github.io/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksxgithub%2Fpipe-trait","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fksxgithub%2Fpipe-trait","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksxgithub%2Fpipe-trait/lists"}