Skip to content

Commit 6b6685b

Browse files
authored
Merge pull request #65 from garro95/aborgna-q-ab/msrv
Downgrade and declare minimum Rust version
2 parents 74a99a4 + ef88733 commit 6b6685b

File tree

9 files changed

+23
-13
lines changed

9 files changed

+23
-13
lines changed

.github/workflows/static-checks.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,11 @@ jobs:
3434
with:
3535
components: miri
3636
- run: cargo miri test
37+
38+
msrv-verify:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
- uses: dtolnay/rust-toolchain@stable
43+
- run: cargo install cargo-msrv
44+
- run: cargo msrv verify --all-features

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ readme = "README.md"
99
keywords = ["priority", "queue", "heap"]
1010
categories = ["data-structures", "algorithms"]
1111
license = "LGPL-3.0-or-later OR MPL-2.0"
12-
edition = "2024"
12+
edition = "2021"
13+
rust-version = "1.65.0"
1314

1415
[build-dependencies]
1516
autocfg = "1"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
[![crate](https://img.shields.io/crates/v/priority-queue.svg)](https://crates.io/crates/priority-queue)
33
[![Build](https://github.com/garro95/priority-queue/actions/workflows/build.yml/badge.svg)](https://github.com/garro95/priority-queue/actions/workflows/build.yml)
44
[![Test](https://github.com/garro95/priority-queue/actions/workflows/test.yml/badge.svg)](https://github.com/garro95/priority-queue/actions/workflows/test.yml)
5+
![MSRV](https://img.shields.io/crates/msrv/priority-queue)
56

67
This crate implements a Priority Queue with a function to change the priority of an object.
78
Priority and items are stored in an `IndexMap` and the queue is implemented as a Heap of indexes.

benches/priority_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ mod benchmarks {
3333
extern crate test;
3434
use hashbrown::hash_map::DefaultHashBuilder;
3535
use priority_queue::{DoublePriorityQueue, PriorityQueue};
36-
use test::{Bencher, black_box};
36+
use test::{black_box, Bencher};
3737

3838
#[bench]
3939
fn push_and_pop(b: &mut Bencher) {

src/double_priority_queue/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ pub mod iterators;
3434
#[cfg(not(feature = "std"))]
3535
use std::vec::Vec;
3636

37-
use crate::TryReserveError;
3837
use crate::core_iterators::*;
3938
use crate::store::{Index, Position, Store};
39+
use crate::TryReserveError;
4040
use iterators::*;
4141

4242
use std::borrow::Borrow;
@@ -612,7 +612,7 @@ where
612612
///
613613
/// Computes in **O(log(N))** time.
614614
pub fn push_increase(&mut self, item: I, priority: P) -> Option<P> {
615-
if self.get_priority(&item).is_none_or(|p| priority > *p) {
615+
if self.get_priority(&item).map_or(true, |p| priority > *p) {
616616
self.push(item, priority)
617617
} else {
618618
Some(priority)
@@ -650,7 +650,7 @@ where
650650
///
651651
/// Computes in **O(log(N))** time.
652652
pub fn push_decrease(&mut self, item: I, priority: P) -> Option<P> {
653-
if self.get_priority(&item).is_none_or(|p| priority < *p) {
653+
if self.get_priority(&item).map_or(true, |p| priority < *p) {
654654
self.push(item, priority)
655655
} else {
656656
Some(priority)

src/priority_queue/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ pub mod iterators;
3535
#[cfg(not(feature = "std"))]
3636
use std::vec::Vec;
3737

38-
use crate::TryReserveError;
3938
use crate::core_iterators::*;
4039
use crate::store::{Index, Position, Store};
40+
use crate::TryReserveError;
4141
use iterators::*;
4242

4343
use std::borrow::Borrow;
@@ -486,7 +486,7 @@ where
486486
///
487487
/// Computes in **O(log(N))** time.
488488
pub fn push_increase(&mut self, item: I, priority: P) -> Option<P> {
489-
if self.get_priority(&item).is_none_or(|p| priority > *p) {
489+
if self.get_priority(&item).map_or(true, |p| priority > *p) {
490490
self.push(item, priority)
491491
} else {
492492
Some(priority)
@@ -524,7 +524,7 @@ where
524524
///
525525
/// Computes in **O(log(N))** time.
526526
pub fn push_decrease(&mut self, item: I, priority: P) -> Option<P> {
527-
if self.get_priority(&item).is_none_or(|p| priority < *p) {
527+
if self.get_priority(&item).map_or(true, |p| priority < *p) {
528528
self.push(item, priority)
529529
} else {
530530
Some(priority)

src/store.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ use std::vec::Vec;
3030

3131
// an improvement in terms of complexity would be to use a bare HashMap
3232
// as vec instead of the IndexMap
33-
use crate::TryReserveError;
3433
use crate::core_iterators::*;
34+
use crate::TryReserveError;
3535

3636
use std::borrow::Borrow;
3737
use std::cmp::{Eq, Ord};
@@ -332,8 +332,8 @@ where
332332
self.map.retain2(predicate);
333333
if self.map.len() != self.size {
334334
self.size = self.map.len();
335-
self.heap = (0..self.size).into_iter().map(|i| Index(i)).collect();
336-
self.qp = (0..self.size).into_iter().map(|p| Position(p)).collect();
335+
self.heap = (0..self.size).map(Index).collect();
336+
self.qp = (0..self.size).map(Position).collect();
337337
}
338338
}
339339

tests/double_priority_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ mod doublepq_tests {
10401040
#[cfg(all(feature = "serde", test))]
10411041
mod serde_tests_basics {
10421042
use priority_queue::DoublePriorityQueue;
1043-
use serde_test::{Token, assert_tokens};
1043+
use serde_test::{assert_tokens, Token};
10441044
#[test]
10451045
fn serde_empty() {
10461046
let pq: DoublePriorityQueue<String, i32> = DoublePriorityQueue::new();

tests/priority_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ mod pqueue_tests {
854854
#[cfg(all(feature = "serde", test))]
855855
mod serde_tests_basics {
856856
use priority_queue::PriorityQueue;
857-
use serde_test::{Token, assert_tokens};
857+
use serde_test::{assert_tokens, Token};
858858
#[test]
859859
fn serde_empty() {
860860
let pq: PriorityQueue<String, i32> = PriorityQueue::new();

0 commit comments

Comments
 (0)