GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - nikstur/uapi-version: Compare versions according to the UAPI Version Format Specification

BranchesTags
Open more actions menu

Latest commit

 

History

35 Commits
35 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
nix
nix
 
 
src
src
 
 
tests
tests
 
 
.envrc
.envrc
 
 
.gitignore
.gitignore
 
 
Cargo.lock
Cargo.lock
 
 
Cargo.toml
Cargo.toml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
flake.lock
flake.lock
 
 
flake.nix
flake.nix
 
 

Repository files navigation

uapi-version

Compare versions according to the UAPI Version Format Specification.

This library is written purely in Rust and does not rely on any third party dependencies. It is #![no_std] and can thus, for example, also be used for UEFI development.

Uses the same test suite that systemd uses to test their strverscmp_improved() function.

Any deviation from the UAPI specification is a bug. Please report it if you find one!

Usage

Add uapi-version to your Cargo.toml:

cargo add uapi-version

You can compare two versions:

use std::cmp::Ordering;

use uapi_version::Version;

fn main() {
    let a = Version::from("225.1");
    let b = Version::from("2");
    assert_eq!(a.cmp(&b), Ordering::Greater)
}

You can sort a list of versions:

use uapi_version::Version;

fn main() {
    let mut versions = [
        "5.2",
        "abc-5",
        "1.0.0~rc1",
    ].map(Version::from);

    versions.sort();

    assert_eq!(versions, [ "abc-5", "1.0.0~rc1", "5.2" ].map(Version::from))
}

You can also compare version strings directly:

use std::cmp::Ordering;

use uapi_version::strverscmp;

fn main() {
    assert_eq!(strverscmp("124", "123"), Ordering::Greater)
}

About

Compare versions according to the UAPI Version Format Specification

docs.rs/uapi-version/latest/uapi_version/

Topics

rustsystemduapiversionversions

Resources

Readme
MIT license
Activity

Stars

4 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.