{"id":21576364,"url":"https://github.com/sigurd4/tuple_split","last_synced_at":"2025-03-18T07:14:01.424Z","repository":{"id":143647679,"uuid":"616548578","full_name":"sigurd4/tuple_split","owner":"sigurd4","description":"An extension for the tupleops crate which adds a trait for splitting tuples by an index.","archived":false,"fork":false,"pushed_at":"2023-03-20T16:11:48.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-25T14:22:28.315Z","etag":null,"topics":["const","rust","split","trait","tuple"],"latest_commit_sha":null,"homepage":"","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/sigurd4.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,"governance":null}},"created_at":"2023-03-20T15:48:47.000Z","updated_at":"2024-02-08T21:27:46.000Z","dependencies_parsed_at":"2023-12-14T12:45:55.498Z","dependency_job_id":null,"html_url":"https://github.com/sigurd4/tuple_split","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"d9450ad4ae0fe6fc8ca1f4100e4c492d44180ad1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigurd4%2Ftuple_split","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigurd4%2Ftuple_split/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigurd4%2Ftuple_split/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigurd4%2Ftuple_split/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sigurd4","download_url":"https://codeload.github.com/sigurd4/tuple_split/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244173554,"owners_count":20410300,"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":["const","rust","split","trait","tuple"],"created_at":"2024-11-24T12:16:16.499Z","updated_at":"2025-03-18T07:14:01.405Z","avatar_url":"https://github.com/sigurd4.png","language":"Rust","readme":"[![Build Status (nightly)](https://github.com/sigurd4/tuple_split/workflows/Build-nightly/badge.svg)](https://github.com/sigurd4/tuple_split/actions/workflows/build-nightly.yml)\n[![Build Status (nightly, all features)](https://github.com/sigurd4/tuple_split/workflows/Build-nightly-all-features/badge.svg)](https://github.com/sigurd4/tuple_split/actions/workflows/build-nightly-all-features.yml)\n\n[![Build Status (stable)](https://github.com/sigurd4/tuple_split/workflows/Build-stable/badge.svg)](https://github.com/sigurd4/tuple_split/actions/workflows/build-stable.yml)\n[![Build Status (stable, all features)](https://github.com/sigurd4/tuple_split/workflows/Build-stable-all-features/badge.svg)](https://github.com/sigurd4/tuple_split/actions/workflows/build-stable-all-features.yml)\n\n[![Test Status](https://github.com/sigurd4/tuple_split/workflows/Test/badge.svg)](https://github.com/sigurd4/tuple_split/actions/workflows/test.yml)\n[![Lint Status](https://github.com/sigurd4/tuple_split/workflows/Lint/badge.svg)](https://github.com/sigurd4/tuple_split/actions/workflows/lint.yml)\n\n[![Latest Version](https://img.shields.io/crates/v/tuple_split.svg)](https://crates.io/crates/tuple_split)\n[![License:MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Documentation](https://img.shields.io/docsrs/tuple_split)](https://docs.rs/tuple_split)\n[![Coverage Status](https://img.shields.io/codecov/c/github/sigurd4/tuple_split)](https://app.codecov.io/github/sigurd4/tuple_split)\n\n# tuple_split\n\nThis crate an extension for the [tupleops](https://crates.io/crates/tupleops) crate.\n\n[tupleops](https://crates.io/crates/tupleops) contains many useful features for manipulating tuples and using tuples in generic code. However, it does not support any kind of splitting of tuples. This crate adds that feature.\n\n## Examples\n\n```rust\nlet t = (32, 0.707, \"test\");\n\n// Splitting tuples by index\nlet (l, r) = tuple_split::split_tuple_at::\u003c0, _\u003e(t);\nassert_eq!(t, tupleops::concat_tuples(l, r));\n\nlet (l, r) = tuple_split::split_tuple_at::\u003c1, _\u003e(t);\nassert_eq!(t, tupleops::concat_tuples(l, r));\n\nlet (l, r) = tuple_split::split_tuple_at::\u003c2, _\u003e(t);\nassert_eq!(t, tupleops::concat_tuples(l, r));\n\nlet (l, r) = tuple_split::split_tuple_at::\u003c3, _\u003e(t);\nassert_eq!(t, tupleops::concat_tuples(l, r));\n\n// Splitting tuples given a left side\nlet (l, r) = tuple_split::split_tuple_into_left::\u003c(u8, f32), _\u003e(t);\nassert_eq!(t, tupleops::concat_tuples(l, r));\n\n// Splitting tuples given a right side\nlet (l, r) = tuple_split::split_tuple_into_right::\u003c(\u0026str,), _\u003e(t);\nassert_eq!(t, tupleops::concat_tuples(l, r));\n\n// Splitting tuples given both sides\nlet (l, r) = tuple_split::split_tuple_into::\u003c(u8, f32), (\u0026str)\u003e(t);\nassert_eq!(t, tupleops::concat_tuples(l, r));\n```\n\n## Split by index\n\nTuples can be split by a const-generic index. To use this feature, put `#![feature(generic_const_exprs)]` on the top of your `lib.rs` or `main.rs`.\n\n### Example\n\n```rust\n#![feature(generic_const_exprs)]\n\nlet t = (1, 1.0, \"test\");\n\nlet (l, r) = tuple_split::split_tuple_at::\u003c2, _\u003e(t);\n\nassert_eq!(t, tupleops::concat_tuples(l, r));\n```\n\n## Split by type\n\nThe type of tuple you want from the split operation can be used instead of an index. This does not require `#![feature(generic_const_exprs)]`. Either the left, right or both can be provided as a generic type.\n\n### Examples\n\n#### Left\n\n```rust\nlet t = (1, 1.0, \"test\");\n\nlet (l, r) = tuple_split::split_tuple_into_left::\u003c(u8, f32), _\u003e(t);\n\nassert_eq!(t, tupleops::concat_tuples(l, r));\n```\n\n#### Right\n\n```rust\nlet t = (1, 1.0, \"test\");\n\nlet (l, r) = tuple_split::split_tuple_into_right::\u003c(\u0026str,), _\u003e(t);\n\nassert_eq!(t, tupleops::concat_tuples(l, r));\n```\n\n#### Both\n\n```rust\nlet t = (1, 1.0, \"test\");\n\nlet (l, r) = tuple_split::split_tuple_into::\u003c(u8, f32), (\u0026str,)\u003e(t);\n\nassert_eq!(t, tupleops::concat_tuples(l, r));\n```\n\n## Tuple sizes\n\nBy default, this crate operates with tuples of up to 16 elements, just like the [tupleops](https://crates.io/crates/tupleops) crate. If you want to use differently sized tuples, use the features `8`, `16`, `32`, `64`, `96`, `128`, `160`, `192`, `224` or `256` to set the maximum supported tuple size.\n\nThe `dont_hurt_yourself_by_using_all_features` is there to prevent usage of tuples bigger than 8 if `cargo` is ran with the flag `--all-features`. Using a tuple size above 16 is highly discouraged as it will make compilation time unbearably long. Compilation time will increase exponentially. You have been warned.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigurd4%2Ftuple_split","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsigurd4%2Ftuple_split","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigurd4%2Ftuple_split/lists"}