8000 Add Examples to Readme · Rust-Python-Packaging/pyver@b530d1a · GitHub
[go: up one dir, main page]

Skip to content

Commit b530d1a

Browse files
committed
Add Examples to Readme
- Added additional examples - Added Link to crates.io - Added Link to docs.rs - Changed License tag to use crates.io
1 parent 5bf0105 commit b530d1a

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# PyVer
22

33
<!-- markdownlint-disable MD013 -->
4-
![GitHub](https://img.shields.io/github/license/Allstreamer/pyver) [![🧪 Tests](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml) [![🖋 Check linting](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml) [![🔨 Build](https://github.com/Allstreamer/pyver/actions/workflows/build.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/build.yml) [![📦 Package](https://github.com/Allstreamer/pyver/actions/workflows/package.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/package.yml) [![📄 Build docs](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml) [![👔 Check formatting](https://github.com/Allstreamer/pyver/actions/workflows/format.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/format.yml)
4+
![Crates.io](https://img.shields.io/crates/l/pyver) ![Crates.io](https://img.shields.io/crates/v/pyver) ![docs.rs](https://img.shields.io/docsrs/pyver) [![🧪 Tests](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/tests.yml) [![🖋 Check linting](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/lint.yml) [![🔨 Build](https://github.com/Allstreamer/pyver/actions/workflows/build.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/build.yml) [![📦 Package](https://github.com/Allstreamer/pyver/actions/workflows/package.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/package.yml) [![📄 Build docs](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/docs.yml) [![👔 Check formatting](https://github.com/Allstreamer/pyver/actions/workflows/format.yml/badge.svg)](https://github.com/Allstreamer/pyver/actions/workflows/format.yml)
55
<!-- markdownlint-enable MD013 -->
66

77
> **Python PEP-440 Version Parser**
@@ -17,6 +17,7 @@ version numbers and for comparisons between
1717
pyver = "1"
1818
```
1919

20+
The following is an example for initilizing and comparing two version strings
2021
```Rust
2122
use pyver::PackageVersion;
2223

@@ -26,6 +27,35 @@ let b = PackageVersion::new("v1.0a2.dev457").unwrap();
2627
assert_eq!(a < b, true);
2728
```
2829

30+
Comparing single version components
31+
```Rust
32+
use pyver::PackageVersion;
33+
34+
let a = PackageVersion::new("1!1.323.dev2").unwrap();
35+
let b = PackageVersion::new("v3.2.dev2").unwrap();
36+
37+
// Check that both have the same dev version
38+
assert_eq!(a.dev, b.dev);
39+
```
40+
41+
Seperation of version identifiers
42+
```Rust
43+
use pyver::PackageVersion;
44+
45+
let version = PackageVersion::new("v1.23.dev2").unwrap();
46+
47+
println!("{:?}", version.release.major);
48+
// > 1
49+
50+
println!("{:?}", version.release.minor);
51+
// > 2
52+
53+
println!("{:?}", version.dev);
54+
// > Some(DevHead { dev_num: Some(2) })
55+
```
56+
57+
See more examples at the [docs](https://docs.rs/pyver/latest/pyver/)
58+
2959
## Contribution
3060

3161
For now Contributions will be quite loose.

0 commit comments

Comments
 (0)
0