Version Operators

Rust library for comparing and manipulating version numbers

Byte size of Version Open Issues Open Pull Requests Latest commits Build Status



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...

Bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh


Quick Start

This repository is a Rust library, define it as a dependency within a project Cargo.toml file...

Cargo.toml (snip)

toml [dependencies] version_operators = "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)

Rust use version_operators::Version;


Usage

src/main.rs (example)

```Rust use version_operators::Version;

fn main() { let version = Version::from_str("1.14.3");

let expected = vec![1, 14, 3];

assert_eq!(version.to_vector(), expected);

} ```


Check the examples/ directory of this repository for more detailed examples of how this project may be utilized within other applications, use cargo run --example <name> to execute, eg...

examples/version-compare.rs

```Bash cargo run --example version-compare '1.14.3' '-lt' '1.14.4'

> true

cargo run --example version-compare '1.14.3' '==' '1.14.4'

> false

```

examples/version-math.rs

```Bash cargo run --example version-math '1.14.4' '-add' '1.14.3'

> [2, 28, 7]

cargo run --example version-math '1.14.4' '-sub' '1.14.3'

> [0, 0, 1]

```


Notes

Until version 0.1.0; methods, data structure properties, and implementation name(s) may have names and/or behavior change!

This repository may not be feature complete and/or fully functional, Pull Requests that add features or fix bugs are certainly welcomed.

Currently math and comparison operators start with the most significant bits of each version. This means that when operating on versions of unequal length it may be useful to zero-pad the shorter version...

```Rust use version_operators::Version;

fn main() { let versionone = Version.fromstr("1.14.3"); let versioninc = Version.fromstr("0.0.1"); let newversion = versionone + version_inc;

assert_eq!(new_version.to_vector(), vec![1, 14, 4]);

} ```

Check source code of examples/version-increment.rs for an example of targeting a portion of a version to increment...

```Bash cargo run --example version-increment '1.14.3' '1'

> [1, 15, 3]

```


Contributing

Options for contributing to version and rust-utilities


Forking

Start making a Fork of this repository to an account that you have write permissions for.

```Bash cd ~/git/hub/rust-utilities/version_operators

git remote add fork git@github.com:/version_operators.git ```

Bash cargo test

```Bash cd ~/git/hub/rust-utilities/version_operators

git commit -F- <<'EOF' :bug: Fixes #42 Issue

Edits

git push fork main ```

Note, the -u option may be used to set fork as the default remote, eg. git push -u fork main however, this will also default the fork remote for pulling from too! Meaning that pulling updates from origin must be done explicitly, eg. git pull origin main

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 ![sponsorshields_ioliberapay] on a repeating basis.

Regardless of if you're able to financially support projects such as version 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


License

```LICENSE Rust library for comparing and manipulating version numbers 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.