{"id":16856342,"url":"https://github.com/kijewski/tupleops","last_synced_at":"2025-03-22T06:31:08.258Z","repository":{"id":54675304,"uuid":"398706799","full_name":"Kijewski/tupleops","owner":"Kijewski","description":"Utility library to work with tuples.","archived":false,"fork":false,"pushed_at":"2021-08-25T03:15:21.000Z","size":27,"stargazers_count":17,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T08:53:35.588Z","etag":null,"topics":["no-std","rust","tuples"],"latest_commit_sha":null,"homepage":"https://docs.rs/tupleops","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kijewski.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":"2021-08-22T03:39:59.000Z","updated_at":"2024-12-15T22:01:58.000Z","dependencies_parsed_at":"2022-08-13T23:40:15.633Z","dependency_job_id":null,"html_url":"https://github.com/Kijewski/tupleops","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kijewski%2Ftupleops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kijewski%2Ftupleops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kijewski%2Ftupleops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kijewski%2Ftupleops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kijewski","download_url":"https://codeload.github.com/Kijewski/tupleops/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244918500,"owners_count":20531682,"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":["no-std","rust","tuples"],"created_at":"2024-10-13T14:03:44.340Z","updated_at":"2025-03-22T06:31:07.293Z","avatar_url":"https://github.com/Kijewski.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Utility library to work with tuples.\n\n## Features:\n\n* Test if all elements are `Ok`: **`all_ok()`**\n\n  ```rust\n  assert_eq!(\n      all_ok((good(1), good(2), good(3))),\n      Ok((1, 2, 3)),\n  );\n  assert_eq!(\n      all_ok((good(1), bad(2), good(3))),\n      Err((Ok(1), Err(2), Ok(3)))\n  );\n  ```\n\n* Test if all elements are `Some`: **`all_some()`**\n\n  ```rust\n  assert_eq!(\n      all_some((Some(1), Some(2), Some(3))),\n      Ok((1, 2, 3))\n  );\n  assert_eq!(\n      all_some((Some(1), Option::\u003c()\u003e::None, Some(3))),\n      Err((Some(1), None, Some(3)))\n  );\n  ```\n\n* Prepend an element to a tuple: **`prepend()`**\n\n  ```rust\n  assert_eq!(\n      prepend(1, (2, 3, 4)),\n      (1, 2, 3, 4)\n  );\n  ```\n\n* Append an element to a tuple: **`append()`**\n\n  ```rust\n  assert_eq!(\n      append((1, 2, 3), 4),\n      (1, 2, 3, 4)\n  );\n  ```\n\n* Concatenate two tuples: **`concat_tuples()`**\n\n  ```rust\n  assert_eq!(\n      concat_tuples((1, 2), (3, 4, 5)),\n      (1, 2, 3, 4, 5)\n  );\n  ```\n\n* Concatenate multiple tuples: **`concat_many()`**\n\n  ```rust\n  assert_eq!(\n      concat_many(((), (1,), (2, 3,), (4, 5, 6))),\n      (1, 2, 3, 4, 5, 6)\n  );\n  ```\n\n* Turn a reference to a tuple to a tuple of references: **`ref_tuple()`**\n\n  ```rust\n  assert_eq!(\n      ref_tuple(\u0026(1, 2, 3)),\n      (\u00261, \u00262, \u00263)\n  );\n  ```\n\n* Turn a reference to a mutable tuple to a tuple of mutable references: **`tuple_ref_mut()`**\n\n  ```rust\n  assert_eq!(\n      tuple_ref_mut(\u0026mut (1, 2, 3)),\n      (\u0026mut 1, \u0026mut 2, \u0026mut 3)\n  );\n  ```\n\n* Extract the first element of a tuple: **`unprepend()`**\n\n  ```rust\n  assert_eq!(\n      unprepend((1, 2, 3, 4)),\n      (1, (2, 3, 4))\n  );\n  ```\n\n* Extract the last element of a tuple: **`unappend()`**\n\n  ```rust\n  assert_eq!(\n      unappend((1, 2, 3, 4)),\n      ((1, 2, 3), 4)\n  );\n  ```\n\n* Call a function with the tuple members as arguments: **`apply()`**\n\n  ```rust\n  fn add3(a: u32, b: u32, c: u32) -\u003e u32 { a + b + c }\n\n  let tpl3 = (1, 2, 3);\n  assert_eq!(\n      apply(\u0026add3, tpl3),\n      6\n  );\n  ```\n\n* Element-wise wrap the element of a tuple in `Option`: **`option_tuple()`**\n\n  ```rust\n  assert_eq!(\n      option_tuple(Some((1, 2, 3))),\n      (Some(1), Some(2), Some(3))\n  );\n  ```\n\n* Get the length of a tuple: **`length()`**\n\n  ```rust\n  assert_eq!(\u003c(u8, u16, u32) as TupleLength\u003e::LENGTH, 3);\n  ```\n\n* Map a tuple: **`map_tuple()`**\n\n  ```rust\n  struct MyTupleEnum(usize);\n\n  impl TupleMapper for MyTupleEnum {\n      type MapElem\u003cType\u003e = (usize, Type);\n \n      fn map_elem\u003cElem\u003e(\u0026mut self, elem: Elem) -\u003e Self::MapElem\u003cElem\u003e {\n          let index = self.0;\n          self.0 += 1;\n          (index, elem)\n      }\n  }\n\n  assert_eq!(\n      map_tuple(MyTupleEnum(1), (\"hello\", \"world\", \"!\")),\n      ((1, \"hello\"), (2, \"world\"), (3, \"!\")),\n  )\n  ```\n\n## Supported tuple lengths:\n\nBy default the selected operations are implemented to tuples upto a length of 16 elements\n(`features = [\"default-len\"]`).\n\nYou can specify a higher limit by using `feature = [\"X\"]`, where `X` can be\n8, 16, 32, 64, 96, 128, 160, 192, 224, or 256. A higher number includes all lower numbers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkijewski%2Ftupleops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkijewski%2Ftupleops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkijewski%2Ftupleops/lists"}