Skip to content

Commit e0323e7

Browse files
authored
Merge pull request #227 from japaric/linked_list_impl
Added sorted linked list implementation
2 parents 8d76c2d + 0bac6ca commit e0323e7

File tree

3 files changed

+871
-0
lines changed

3 files changed

+871
-0
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ mod defmt;
102102
pub mod mpmc;
103103
#[cfg(all(has_cas, feature = "cas"))]
104104
pub mod pool;
105+
pub mod sorted_linked_list;
105106
#[cfg(has_atomics)]
106107
pub mod spsc;
107108

src/sealed.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,36 @@ pub mod binary_heap {
2222
}
2323
}
2424

25+
/// Sealed traits and implementations for `LinkedList`
26+
pub mod sorted_linked_list {
27+
use crate::sorted_linked_list::{Max, Min};
28+
use core::cmp::Ordering;
29+
30+
/// The linked list kind: min-list or max-list
31+
pub unsafe trait Kind {
32+
#[doc(hidden)]
33+
fn ordering() -> Ordering;
34+
}
35+
36+
unsafe impl Kind for Min {
37+
fn ordering() -> Ordering {
38+
Ordering::Less
39+
}
40+
}
41+
42+
unsafe impl Kind for Max {
43+
fn ordering() -> Ordering {
44+
Ordering::Greater
45+
}
46+
}
47+
}
48+
49+
#[allow(dead_code)]
50+
#[allow(path_statements)]
51+
pub(crate) const fn smaller_than<const N: usize, const MAX: usize>() {
52+
Assert::<N, MAX>::LESS;
53+
}
54+
2555
#[allow(dead_code)]
2656
#[allow(path_statements)]
2757
pub(crate) const fn greater_than_0<const N: usize>() {

0 commit comments

Comments
 (0)