File tree Expand file tree Collapse file tree 9 files changed +23
-13
lines changed Expand file tree Collapse file tree 9 files changed +23
-13
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ readme = "README.md"
99keywords = [" priority" , " queue" , " heap" ]
1010categories = [" data-structures" , " algorithms" ]
1111license = " 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 ]
1516autocfg = " 1"
Original file line number Diff line number Diff line change 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
67This crate implements a Priority Queue with a function to change the priority of an object.
78Priority and items are stored in an ` IndexMap ` and the queue is implemented as a Heap of indexes.
Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff line change @@ -34,9 +34,9 @@ pub mod iterators;
3434#[ cfg( not( feature = "std" ) ) ]
3535use std:: vec:: Vec ;
3636
37- use crate :: TryReserveError ;
3837use crate :: core_iterators:: * ;
3938use crate :: store:: { Index , Position , Store } ;
39+ use crate :: TryReserveError ;
4040use iterators:: * ;
4141
4242use 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)
Original file line number Diff line number Diff line change @@ -35,9 +35,9 @@ pub mod iterators;
3535#[ cfg( not( feature = "std" ) ) ]
3636use std:: vec:: Vec ;
3737
38- use crate :: TryReserveError ;
3938use crate :: core_iterators:: * ;
4039use crate :: store:: { Index , Position , Store } ;
40+ use crate :: TryReserveError ;
4141use iterators:: * ;
4242
4343use 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)
Original file line number Diff line number Diff 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 ;
3433use crate :: core_iterators:: * ;
34+ use crate :: TryReserveError ;
3535
3636use std:: borrow:: Borrow ;
3737use 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
Original file line number Diff line number Diff line change @@ -1040,7 +1040,7 @@ mod doublepq_tests {
10401040#[ cfg( all( feature = "serde" , test) ) ]
10411041mod 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 ( ) ;
Original file line number Diff line number Diff line change @@ -854,7 +854,7 @@ mod pqueue_tests {
854854#[ cfg( all( feature = "serde" , test) ) ]
855855mod 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 ( ) ;
You can’t perform that action at this time.
0 commit comments