array_tool
Array helpers for Rust. Some of the most common methods you would use on Arrays made available on Vectors. Polymorphic implementations for handling most of your use cases.
Installation
Add the following to your Cargo.toml file
[dependencies]
array_tool = "0.3.5"
And in your rust files where you plan to use it put this at the top
extern crate array_tool;
And if you plan to use all of the Vector helper methods available you may do
use *;
This crate has helpful methods for strings as well.
Usage
use Uniq;
use Shift;
use Intersect;
use Join;
use Times;
use Union;
use Justify;
;
// "asd as df asd".justify_line(16) // input
// "asd as df asd" // return value
// "asd as df asd".justify_line(18) // input
// "asd as df asd" // return value
use SubstMarks;
;
// "asdf asdf asdf".subst_marks(vec![0,5,8], "Z") // input
// "Zsdf ZsdZ asdf" // return value
use WordWrap;
;
// "01234 67 9 BC EFG IJ".word_wrap(6) // input
// "01234\n67 9\nBC\nEFG IJ" // return value
use AfterWhitespace;
;
// "asdf asdf asdf".seek_end_of_whitespace(6) // input
// Some(9) // output
// "asdf".seek_end_of_whitespace(3) // input
// Some(0) // output
// "asdf ".seek_end_of_whitespace(6) // input
// None // ouput
Future plans
Expect methods to become more polymorphic over time (same method implemented for similar & compatible types). I plan to implement many of the methods available for Arrays in higher languages; such as Ruby. Expect regular updates.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.