version_operators

Crates.ioversion_operators
lib.rsversion_operators
version0.0.1
sourcesrc
created_at2021-01-16 03:29:48.22932
updated_at2021-01-16 03:29:48.22932
descriptionRust library for comparing and manipulating version numbers
homepagehttps://github.com/rust-utilities/version_operators
repositoryhttps://github.com/rust-utilities/version_operators
max_upload_size
id342653
size63,485
(S0AndS0)

documentation

README

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

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)

[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)

use version_operators::Version;

Usage

src/main.rs (example)

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

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

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

use version_operators::Version;

fn main() {
    let version_one = Version.from_str("1.14.3");
    let version_inc = Version.from_str("0.0.1");
    let new_version = version_one + 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...

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.

  • Add remote for fork URL. The URL syntax is git@github.com:<NAME>/<REPO>.git...

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

git remote add fork git@github.com:<NAME>/version_operators.git
  • Test changes via cargo...

cargo test
  • Commit your changes and push to your fork, eg. to fix an issue...

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


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


**Edits**


- `<SCRIPT-NAME>` script, fixes some bug reported in issue
EOF


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

  • 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 sponsor__shields_io__liberapay 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

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.

Commit count: 1

cargo fmt