~jordanreger/fold.rs

51206c276e2b5b26c39e22b7cbbedeb78e56eae4 — Jordan Reger 3 months ago b132985 main
license and readme
2 files changed, 61 insertions(+), 0 deletions(-)

A LICENSE
A README.md
A LICENSE => LICENSE +26 -0
@@ 0,0 1,26 @@
Copyright 2023 Jordan Reger 

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this 
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation 
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors 
may be used to endorse or promote products derived from this software without 
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file

A README.md => README.md +35 -0
@@ 0,0 1,35 @@
# `fold(1)` in Rust
This is the UNIX command `fold(1)` implemented in Rust.

## How to use
It is fairly straightforward, as it only takes two parameters:
```rs
fold(str: &'static str, len: Option<usize>) -> String {
  ...
}
```
The default fold width is 80, just like in the original command.

### Example
Here's an example of how to use `fold` in your code:

`src/main.rs`
```rs
use fold::fold;

fn main() {
    let lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Morbi tristique senectus et netus. Id ornare arcu odio ut sem nulla pharetra diam. Commodo sed egestas egestas fringilla phasellus. Quis lectus nulla at volutpat diam ut venenatis tellus.";
    println!("{}", fold(lorem, None));
}
```

`Cargo.toml`
```toml
[package]
name = "fold-test"
version = "0.1.0"
edition = "2021"

[dependencies]
fold = { git = "https://git.sr.ht/~jordanreger/fold.rs" }
```