Iterate Text
Library of helper functions and structures for iterating over text and files
Requirements
This repository requires Rust language/compiler to build from source
As of last update to this ReadMe file, the recommended method of installing Rust is via the installer script...
|
Quick Start
This repository is a Rust library, define it as a dependency within a project Cargo.toml
file...
Cargo.toml
(snip)
[]
= "0.0.1"
Check Rust -- Doc -- Specifying Dependencies for details about defining dependencies.
Then include within a source file via use
statement...
src/main.rs
(snip)
extern crate iterate_text;
use IterateFileCharacters;
use IterateFileLines;
use IterateStringCharacters;
use IterateStringLines;
Usage
Check the examples/
directory of this project for detailed usage examples.
src/main.rs
#!/usr/bin/env rust
use env;
extern crate iterate_text;
use IterateFileLines;
API
Documentation for classes, methods, parameters, and custom types/data-structures
file::characters::IterateFileCharacters
Reads from path, buffer, or descriptor and iterates over characters until EOF is reached
Example
use IterateFileCharacters;
let p = "tests/file/characters/file.txt";
let mut c = new;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
file::lines::IterateFileLines
Reads from file path, buffer, or descriptor and iterates over lines until EOF is reached
use IterateFileLines;
let p = "tests/file/lines/file.txt";
let mut l = new;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
string::characters::IterateStringCharacters
Iterates over characters within string
Example
use IterateStringCharacters;
let s = String from;
let mut c = new;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
string::lines::IterateStringLines
Iterates over lines within string and includes new-line separator
Example
use IterateStringLines;
let s = String from;
let mut l = new;
assert_eq!;
assert_eq!;
assert_eq!;
Notes
The characters
iterators currently use String.char_indices()
which may split certain Unicode characters in unexpected ways.
This repository may not be feature complete and/or fully functional, Pull Requests that add features or fix bugs are certainly welcomed.
Contributing
Options for contributing to iterate-text and rust-utilities
Forking
Start making a Fork of this repository to an account that you have write permissions for.
- Add remote for fork URL. The URL syntax is
git@github.com:<NAME>/<REPO>.git
...
- Ensure all tests pass
- Run any examples by name
- Commit your changes and push to your fork to fix an issue or add a feature...
Note, the
-u
option may be used to setfork
as the default remote, eg.git push -u fork main
however, this will also default thefork
remote for pulling from too! Meaning that pulling updates fromorigin
must be done explicitly, eg.git pull origin main
- Then on GitHub submit a Pull Request through the Web-UI, the URL syntax is
https://github.com/<NAME>/<REPO>/pull/new/<BRANCH>
Note; to decrease the chances of your Pull Request needing modifications before being accepted, please check the dot-github repository for detailed contributing guidelines.
Sponsor
Thanks for even considering it!
Via Liberapay you may on a repeating basis.
Regardless of if you're able to financially support projects such as iterate-text that rust-utilities maintains, please consider sharing projects that are useful with others, because one of the goals of maintaining Open Source repositories is to provide value to the community.
Attribution
-
Matrix --
@kaplan
offered suberb, and efficent, code that totally solved my Rust related issues -
Matrix --
@projectmoon
had excelent instincts of owningline
enabling character iteration -
Matrix --
@tanriol
patently explained why code from@kaplan
was so good, and answered my questions -
StackOverflow -- How do I write a Rust unit test that ensures that a panic has occurred?
-
StackOverflow -- How do I test a code in a sub-sub-directory?
License
Library of helper functions and structures for iterating over text and files
Copyright (C) 2021 S0AndS0
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For further details review full length version of AGPL-3.0 License.