File: version.rs

package info (click to toggle)
rust-pathfinding 4.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,024 kB
  • sloc: sh: 19; makefile: 2
file content (21 lines) | stat: -rw-r--r-- 709 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const VERSION: &str = env!("CARGO_PKG_VERSION");
const README: &str = include_str!("../README.md");

#[test]
fn check_version() {
    let line = README
        .lines()
        .find(|l| l.starts_with("pathfinding = "))
        .expect("no version line found in README.md");
    let version = line.split('"').collect::<Vec<_>>()[1];
    assert!(
        trim(VERSION).starts_with(&trim(version)),
        "Version in README.md ({} - seen as {}) is not compatible with Cargo.toml ({} - seen as {})",
        version, trim(version), VERSION, trim(VERSION),
    );
}

// Keep at most two components (major/minor).
fn trim(version: &str) -> String {
    version.split('.').take(2).collect::<Vec<_>>().join(".")
}