Skip to content

Commit 880aff7

Browse files
committed
Set minimal supported Rust version to 1.75
Current code has `Option::is_none_or()` which released 2024 Oct 17, considering old compiler environment like Ubuntu 24.04 LTS, RHEL 9, replaced it to: ```rust self.unsolicited_messages_tx.as_ref().is_none() || self.unsolicited_messages_tx.as_ref().map(|x| x.is_closed()) ``` Set minimum supported Rust version to 1.75 to `Cargo.toml` and enabled CI test for it. Signed-off-by: Gris Ge <[email protected]>
1 parent 8811b0d commit 880aff7

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

.github/workflows/build.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: build
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
msrv:
12+
name: Build on minimal supported rust
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Install Rust 1.75
19+
run: |
20+
rustup override set 1.75
21+
rustup update 1.75
22+
rustc --version
23+
24+
- name: Build with default feature
25+
run: cargo build
26+
27+
- name: Build with tokio feature
28+
run: cargo build --features tokio_socket
29+
30+
- name: Build with smol_socket feature
31+
run: cargo build --features smol_socket

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ authors = ["Corentin Henry <[email protected]>"]
33
name = "netlink-proto"
44
version = "0.11.4"
55
edition = "2018"
6+
rust-version = "1.75"
67

78
homepage = "https://github.com/rust-netlink/netlink-proto"
89
keywords = ["netlink", "linux", "async"]

src/connection.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,13 @@ where
236236
}
237237
}
238238

239+
// Rust 1.82 has Option::is_none_or() which can simplify
240+
// below checks but that version is released on 2024 Oct. 17 which
241+
// is not available on old OS like Ubuntu 24.04 LTS, RHEL 9 yet.
239242
if ready
240-
|| self
241-
.unsolicited_messages_tx
242-
.as_ref()
243-
.is_none_or(|x| x.is_closed())
243+
|| self.unsolicited_messages_tx.as_ref().is_none()
244+
|| self.unsolicited_messages_tx.as_ref().map(|x| x.is_closed())
245+
== Some(true)
244246
{
245247
// The channel is closed so we can drop the sender.
246248
let _ = self.unsolicited_messages_tx.take();

0 commit comments

Comments
 (0)