Added forgotten file, fixed CI.

This commit is contained in:
Revertron
2026-04-06 02:40:45 +02:00
parent f4c8b1fe42
commit 489f16e462
2 changed files with 65 additions and 3 deletions
+6 -3
View File
@@ -94,9 +94,10 @@ jobs:
name: darwin-arm64
bin_path: ./target/release/alfis
archive_cmd: zip
- os: macos-13
- os: macos-latest
name: darwin-amd64
bin_path: ./target/release/alfis
target: x86_64-apple-darwin
bin_path: ./target/x86_64-apple-darwin/release/alfis
archive_cmd: zip
defaults:
@@ -108,6 +109,8 @@ jobs:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target || '' }}
- name: Install Linux dependencies
if: contains(matrix.os, 'ubuntu')
@@ -121,7 +124,7 @@ jobs:
libayatana-appindicator3-dev
- name: Build release binaries
run: cargo build --release
run: cargo build --release ${{ matrix.target && format('--target {0}', matrix.target) || '' }}
- name: Package zip
env:
+59
View File
@@ -0,0 +1,59 @@
use std::fmt;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Version {
pub major: u16,
pub minor: u16,
pub patch: u16,
}
impl Version {
pub fn parse(s: &str) -> Version {
let parts: Vec<&str> = s.split('.').collect();
Version {
major: parts.get(0).and_then(|s| s.parse().ok()).unwrap_or(0),
minor: parts.get(1).and_then(|s| s.parse().ok()).unwrap_or(0),
patch: parts.get(2).and_then(|s| s.parse().ok()).unwrap_or(0),
}
}
}
impl Default for Version {
fn default() -> Self {
Version { major: 0, minor: 0, patch: 0 }
}
}
impl PartialOrd for Version {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Version {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.major.cmp(&other.major)
.then(self.minor.cmp(&other.minor))
.then(self.patch.cmp(&other.patch))
}
}
impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}.{}.{}", self.major, self.minor, self.patch)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_version_comparison() {
assert!(Version::parse("0.8.9") >= Version::parse("0.8.9"));
assert!(Version::parse("0.8.10") > Version::parse("0.8.9"));
assert!(Version::parse("0.8.8") < Version::parse("0.8.9"));
assert!(Version::parse("0.9.0") > Version::parse("0.8.99"));
assert!(Version::parse("1.0.0") > Version::parse("0.99.99"));
}
}