{"id":13439117,"url":"https://github.com/danielpclark/array_tool","last_synced_at":"2025-04-05T19:12:51.784Z","repository":{"id":1772218,"uuid":"44705484","full_name":"danielpclark/array_tool","owner":"danielpclark","description":"Array helpers for Rust's Vector and String types","archived":false,"fork":false,"pushed_at":"2023-02-06T03:25:43.000Z","size":89,"stargazers_count":76,"open_issues_count":2,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T18:06:59.308Z","etag":null,"topics":["crates","grapheme","iterator","justify","rust","string","vector","wordwrap"],"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/danielpclark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-10-21T21:25:49.000Z","updated_at":"2024-08-28T22:55:30.000Z","dependencies_parsed_at":"2023-07-05T19:16:39.729Z","dependency_job_id":null,"html_url":"https://github.com/danielpclark/array_tool","commit_stats":{"total_commits":102,"total_committers":3,"mean_commits":34.0,"dds":"0.13725490196078427","last_synced_commit":"69b9155f45fc807a1bdc90b2352c35aee0d31fa5"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielpclark%2Farray_tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielpclark%2Farray_tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielpclark%2Farray_tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielpclark%2Farray_tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielpclark","download_url":"https://codeload.github.com/danielpclark/array_tool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247386265,"owners_count":20930619,"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":["crates","grapheme","iterator","justify","rust","string","vector","wordwrap"],"created_at":"2024-07-31T03:01:11.265Z","updated_at":"2025-04-05T19:12:51.750Z","avatar_url":"https://github.com/danielpclark.png","language":"Rust","funding_links":[],"categories":["Libraries","库 Libraries","库","Rust"],"sub_categories":["Data structures","数据结构 Data structures","数据结构"],"readme":"# array_tool\r\n[![Build Status](https://travis-ci.org/danielpclark/array_tool.svg?branch=master)](https://travis-ci.org/danielpclark/array_tool)\r\n[![Build Status](https://ci.appveyor.com/api/projects/status/dffq3dwb8w220q4f/branch/master?svg=true)](https://ci.appveyor.com/project/danielpclark/array-tool/branch/master)\r\n[![Documentation](https://img.shields.io/badge/docs-100%25-brightgreen.svg)](http://danielpclark.github.io/array_tool/index.html)\r\n[![crates.io version](https://img.shields.io/crates/v/array_tool.svg)](https://crates.io/crates/array_tool)\r\n[![License](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)]()\r\n\r\nArray helpers for Rust.  Some of the most common methods you would\r\nuse on Arrays made available on Vectors.  Polymorphic implementations\r\nfor handling most of your use cases.\r\n\r\n\r\n### Installation\r\n\r\nAdd the following to your Cargo.toml file\r\n```toml\r\n[dependencies]\r\narray_tool = \"~1.0.3\"\r\n```\r\n\r\nAnd in your rust files where you plan to use it put this at the top\r\n```rust\r\nextern crate array_tool;\r\n```\r\n\r\nAnd if you plan to use all of the Vector helper methods available you may do\r\n```rust\r\nuse array_tool::vec::*;\r\n```\r\n\r\nThis crate has helpful methods for strings as well.\r\n\r\n## Iterator Usage\r\n\r\n```rust\r\nuse array_tool::iter::ZipOpt;\r\nfn zip_option\u003cU: Iterator\u003e(self, other: U) -\u003e ZipOption\u003cSelf, U\u003e\r\n  where Self: Sized, U: IntoIterator;\r\n  //  let a = vec![1];\r\n  //  let b = vec![];\r\n  //  a.zip_option(b).next()      // input\r\n  //  Some((Some(1), None))       // return value\r\n```\r\n\r\n## Vector Usage\r\n\r\n```rust\r\npub fn uniques\u003cT: PartialEq + Clone\u003e(a: Vec\u003cT\u003e, b: Vec\u003cT\u003e) -\u003e Vec\u003cVec\u003cT\u003e\u003e\r\n  //  array_tool::uniques(vec![1,2,3,4,5], vec![2,5,6,7,8]) // input\r\n  //  vec![vec![1,3,4], vec![6,7,8]]                        // return value\r\n\r\nuse array_tool::vec::Uniq;\r\nfn uniq(\u0026self, other: Vec\u003cT\u003e) -\u003e Vec\u003cT\u003e;\r\n  //  vec![1,2,3,4,5,6].uniq( vec![1,2,5,7,9] ) // input\r\n  //  vec![3,4,6]                               // return value\r\nfn uniq_via\u003cF: Fn(\u0026T, \u0026T) -\u003e bool\u003e(\u0026self, other: Self, f: F) -\u003e Self;\r\n  //  vec![1,2,3,4,5,6].uniq_via( vec![1,2,5,7,9], |\u0026l, r| l == r + 2 ) // input \r\n  //  vec![1,2,4,6]                                                     // return value\r\nfn unique(\u0026self) -\u003e Vec\u003cT\u003e;\r\n  //  vec![1,2,1,3,2,3,4,5,6].unique()          // input\r\n  //  vec![1,2,3,4,5,6]                         // return value\r\nfn unique_via\u003cF: Fn(\u0026T, \u0026T) -\u003e bool\u003e(\u0026self, f: F) -\u003e Self;\r\n  //  vec![1.0,2.0,1.4,3.3,2.1,3.5,4.6,5.2,6.2].\r\n  //  unique_via( |l: \u0026f64, r: \u0026f64| l.floor() == r.floor() ) // input\r\n  //  vec![1.0,2.0,3.3,4.6,5.2,6.2]                           // return value\r\nfn is_unique(\u0026self) -\u003e bool;\r\n  //  vec![1,2,1,3,4,3,4,5,6].is_unique()       // input\r\n  //  false                                     // return value\r\n  //  vec![1,2,3,4,5,6].is_unique()             // input\r\n  //  true                                      // return value\r\n\r\nuse array_tool::vec::Shift;\r\nfn unshift(\u0026mut self, other: T);    // no return value, modifies \u0026mut self directly\r\n  //  let mut x = vec![1,2,3];\r\n  //  x.unshift(0);\r\n  //  assert_eq!(x, vec![0,1,2,3]);\r\nfn shift(\u0026mut self) -\u003e Option\u003cT\u003e;\r\n  //  let mut x = vec![0,1,2,3];\r\n  //  assert_eq!(x.shift(), Some(0));\r\n  //  assert_eq!(x, vec![1,2,3]);\r\n\r\nuse array_tool::vec::Intersect;\r\nfn intersect(\u0026self, other: Vec\u003cT\u003e) -\u003e Vec\u003cT\u003e;\r\n  //  vec![1,1,3,5].intersect(vec![1,2,3]) // input\r\n  //  vec![1,3]                            // return value\r\nfn intersect_if\u003cF: Fn(\u0026T, \u0026T) -\u003e bool\u003e(\u0026self, other: Vec\u003cT\u003e, validator: F) -\u003e Vec\u003cT\u003e;\r\n  //  vec!['a','a','c','e'].intersect_if(vec!['A','B','C'], |l, r| l.eq_ignore_ascii_case(r)) // input\r\n  //  vec!['a','c']                                                                           // return value\r\n\r\nuse array_tool::vec::Join;\r\nfn join(\u0026self, joiner: \u0026'static str) -\u003e String;\r\n  //  vec![1,2,3].join(\",\")                // input\r\n  //  \"1,2,3\"                              // return value\r\n\r\nuse array_tool::vec::Times;\r\nfn times(\u0026self, qty: i32) -\u003e Vec\u003cT\u003e;\r\n  //  vec![1,2,3].times(3)                 // input\r\n  //  vec![1,2,3,1,2,3,1,2,3]              // return value\r\n\r\nuse array_tool::vec::Union;\r\nfn union(\u0026self, other: Vec\u003cT\u003e) -\u003e Vec\u003cT\u003e;\r\n  //  vec![\"a\",\"b\",\"c\"].union(vec![\"c\",\"d\",\"a\"])   // input\r\n  //  vec![ \"a\", \"b\", \"c\", \"d\" ]                   // return value\r\n```\r\n\r\n## String Usage\r\n\r\n```rust\r\nuse array_tool::string::ToGraphemeBytesIter;\r\nfn grapheme_bytes_iter(\u0026'a self) -\u003e GraphemeBytesIter\u003c'a\u003e;\r\n  //  let string = \"a s—d féZ\";\r\n  //  let mut graphemes = string.grapheme_bytes_iter()\r\n  //  graphemes.skip(3).next();            // input\r\n  //  [226, 128, 148]                      // return value for emdash `—`\r\n\r\nuse array_tool::string::Squeeze;\r\nfn squeeze(\u0026self, targets: \u0026'static str) -\u003e String;\r\n  //  \"yellow moon\".squeeze(\"\")            // input\r\n  //  \"yelow mon\"                          // return value\r\n  //  \"  now   is  the\".squeeze(\" \")       // input\r\n  //  \" now is the\"                        // return value\r\n\r\nuse array_tool::string::Justify;\r\nfn justify_line(\u0026self, width: usize) -\u003e String;\r\n  //  \"asd as df asd\".justify_line(16)     // input\r\n  //  \"asd  as  df  asd\"                   // return value\r\n  //  \"asd as df asd\".justify_line(18)     // input\r\n  //  \"asd   as   df  asd\"                 // return value\r\n\r\nuse array_tool::string::SubstMarks;\r\nfn subst_marks(\u0026self, marks: Vec\u003cusize\u003e, chr: \u0026'static str) -\u003e String;\r\n  //  \"asdf asdf asdf\".subst_marks(vec![0,5,8], \"Z\") // input\r\n  //  \"Zsdf ZsdZ asdf\"                               // return value\r\n\r\nuse array_tool::string::WordWrap;\r\nfn word_wrap(\u0026self, width: usize) -\u003e String;\r\n  //  \"01234 67 9 BC EFG IJ\".word_wrap(6)  // input\r\n  //  \"01234\\n67 9\\nBC\\nEFG IJ\"            // return value\r\n\r\nuse array_tool::string::AfterWhitespace;\r\nfn seek_end_of_whitespace(\u0026self, offset: usize) -\u003e Option\u003cusize\u003e;\r\n  //  \"asdf           asdf asdf\".seek_end_of_whitespace(6) // input\r\n  //  Some(9)                                              // return value\r\n  //  \"asdf\".seek_end_of_whitespace(3)                     // input\r\n  //  Some(0)                                              // return value\r\n  //  \"asdf           \".seek_end_of_whitespace(6)          // input\r\n  //  None                                                 // return_value\r\n\r\n```\r\n\r\n## Future plans\r\n\r\nExpect methods to become more polymorphic over time (same method implemented\r\nfor similar \u0026 compatible types).  I plan to implement many of the methods\r\navailable for Arrays in higher languages; such as Ruby. Expect regular updates.\r\n\r\n## License\r\n\r\nLicensed under either of\r\n\r\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\r\n * MIT license ([MIT-LICENSE](MIT-LICENSE) or http://opensource.org/licenses/MIT)\r\n\r\nat your option.\r\n\r\n### Contribution\r\n\r\nUnless you explicitly state otherwise, any contribution intentionally submitted\r\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any\r\nadditional terms or conditions.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielpclark%2Farray_tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielpclark%2Farray_tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielpclark%2Farray_tool/lists"}