Skip to content

Commit e973e12

Browse files
authored
Merge pull request #41 from orxfun/migration-to-2024-edition
Migration to 2024 edition
2 parents 5c11b0e + e4ae789 commit e973e12

16 files changed

+143
-89
lines changed

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
toolchain: ["stable"]
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Install toolchain
24+
uses: dtolnay/rust-toolchain@master
25+
with:
26+
toolchain: ${{ matrix.toolchain }}
27+
28+
- name: Install 32bit target
29+
run: rustup target add i686-unknown-linux-musl
30+
- name: Install wasm target
31+
run: rustup target add wasm32v1-none
32+
- name: Install miri
33+
run: rustup component add --toolchain nightly-x86_64-unknown-linux-gnu miri
34+
- name: Install no-std-check
35+
run: cargo install cargo-no-std-check
36+
37+
- name: Build
38+
run: cargo build --verbose
39+
- name: Build-32bit
40+
run: cargo build --verbose --target i686-unknown-linux-musl
41+
- name: Build-wasm
42+
run: cargo build --verbose --target wasm32v1-none
43+
44+
- name: Test
45+
run: cargo test --verbose
46+
- name: Test-32bit
47+
run: cargo test --verbose --target i686-unknown-linux-musl
48+
- name: Check-wasm
49+
run: cargo check --verbose --target wasm32v1-none
50+
51+
- name: Clippy
52+
run: cargo clippy -- -D warnings --verbose
53+
54+
- name: Miri
55+
run: cargo +nightly miri test --verbose
56+
57+
- name: NoStd
58+
run: cargo +nightly no-std-check

Cargo.toml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "orx-linked-list"
3-
version = "3.6.0"
4-
edition = "2021"
3+
version = "3.7.0"
4+
edition = "2024"
55
authors = ["orxfun <[email protected]>"]
66
description = "A linked list implementation with unique features and an extended list of constant time methods providing high performance traversals and mutations."
77
license = "MIT OR Apache-2.0"
@@ -10,24 +10,25 @@ keywords = ["linked", "list", "doubly", "singly", "pinned"]
1010
categories = ["data-structures", "rust-patterns", "no-std"]
1111

1212
[dependencies]
13-
orx-pseudo-default = { version = "2.0.0", default-features = false }
14-
orx-pinned-vec = "3.15"
15-
orx-fixed-vec = "3.15"
16-
orx-split-vec = "3.15"
17-
orx-selfref-col = "2.7"
18-
orx-iterable = { version = "1.2.0", default-features = false }
13+
orx-iterable = { version = "1.3.0", default-features = false }
14+
orx-pseudo-default = { version = "2.1.0", default-features = false }
15+
orx-pinned-vec = "3.16.0"
16+
orx-fixed-vec = "3.16.0"
17+
orx-split-vec = "3.16.0"
18+
orx-selfref-col = "2.8.0"
19+
1920

2021
[dev-dependencies]
21-
clap = { version = "4.5.27", features = ["derive"] }
22+
clap = { version = "4.5.35", features = ["derive"] }
2223
criterion = "0.5"
23-
rand = "0.8.5"
24-
rand_chacha = "0.3.1"
24+
rand = "0.9.0"
25+
rand_chacha = "0.9.0"
2526
test-case = "3.3.1"
2627

2728
[features]
2829
default = []
2930
validation = []
3031

3132
[[bench]]
32-
name = "doubly_shuffling_around"
33+
name = "doubly_mutation_ends"
3334
harness = false

benches/doubly_iter.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
1+
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
22
use orx_linked_list::*;
33
use orx_selfref_col::MemoryPolicy;
44
use rand::prelude::*;
@@ -15,15 +15,15 @@ enum Action {
1515
fn get_test_data(n: usize) -> Vec<Action> {
1616
let mut rng = ChaCha8Rng::seed_from_u64(56456);
1717
let mut vec: Vec<_> = (0..n)
18-
.map(|_| match rng.gen::<f32>() {
19-
x if x < 0.5 => Action::PushBack(rng.gen_range(0..n).to_string()),
20-
_ => Action::PushFront(rng.gen_range(0..n).to_string()),
18+
.map(|_| match rng.random::<f32>() {
19+
x if x < 0.5 => Action::PushBack(rng.random_range(0..n).to_string()),
20+
_ => Action::PushFront(rng.random_range(0..n).to_string()),
2121
})
2222
.collect();
2323
for _ in 0..2 * n {
24-
let action = match rng.gen::<f32>() {
25-
x if x < 0.25 => Action::PushBack(rng.gen_range(0..n).to_string()),
26-
x if x < 0.50 => Action::PushFront(rng.gen_range(0..n).to_string()),
24+
let action = match rng.random::<f32>() {
25+
x if x < 0.25 => Action::PushBack(rng.random_range(0..n).to_string()),
26+
x if x < 0.50 => Action::PushFront(rng.random_range(0..n).to_string()),
2727
x if x < 0.75 => Action::PopBack,
2828
_ => Action::PopFront,
2929
};

benches/doubly_iter_rev.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
1+
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
22
use orx_linked_list::*;
33
use orx_selfref_col::MemoryPolicy;
44
use rand::prelude::*;
@@ -15,15 +15,15 @@ enum Action {
1515
fn get_test_data(n: usize) -> Vec<Action> {
1616
let mut rng = ChaCha8Rng::seed_from_u64(56456);
1717
let mut vec: Vec<_> = (0..n)
18-
.map(|_| match rng.gen::<f32>() {
19-
x if x < 0.5 => Action::PushBack(rng.gen_range(0..n).to_string()),
20-
_ => Action::PushFront(rng.gen_range(0..n).to_string()),
18+
.map(|_| match rng.random::<f32>() {
19+
x if x < 0.5 => Action::PushBack(rng.random_range(0..n).to_string()),
20+
_ => Action::PushFront(rng.random_range(0..n).to_string()),
2121
})
2222
.collect();
2323
for _ in 0..2 * n {
24-
let action = match rng.gen::<f32>() {
25-
x if x < 0.25 => Action::PushBack(rng.gen_range(0..n).to_string()),
26-
x if x < 0.50 => Action::PushFront(rng.gen_range(0..n).to_string()),
24+
let action = match rng.random::<f32>() {
25+
x if x < 0.25 => Action::PushBack(rng.random_range(0..n).to_string()),
26+
x if x < 0.50 => Action::PushFront(rng.random_range(0..n).to_string()),
2727
x if x < 0.75 => Action::PopBack,
2828
_ => Action::PopFront,
2929
};

benches/doubly_mutation_by_pos.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
1+
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
22
use orx_linked_list::*;
33
use orx_selfref_col::MemoryPolicy;
44
use rand::prelude::*;
@@ -15,15 +15,15 @@ enum Action {
1515
fn get_test_data(n: usize) -> Vec<Action> {
1616
let mut rng = ChaCha8Rng::seed_from_u64(56456);
1717
let mut vec: Vec<_> = (0..n)
18-
.map(|_| match rng.gen::<f32>() {
19-
x if x < 0.5 => Action::PushBack(rng.gen_range(0..n) as u32),
20-
_ => Action::PushFront(rng.gen_range(0..n) as u32),
18+
.map(|_| match rng.random::<f32>() {
19+
x if x < 0.5 => Action::PushBack(rng.random_range(0..n) as u32),
20+
_ => Action::PushFront(rng.random_range(0..n) as u32),
2121
})
2222
.collect();
2323
for _ in 0..2 * n {
24-
let action = match rng.gen::<f32>() {
25-
x if x < 0.50 => Action::Insert(rng.gen_range(0..n), rng.gen_range(0..n) as u32),
26-
_ => Action::Remove(rng.gen_range(0..n)),
24+
let action = match rng.random::<f32>() {
25+
x if x < 0.50 => Action::Insert(rng.random_range(0..n), rng.random_range(0..n) as u32),
26+
_ => Action::Remove(rng.random_range(0..n)),
2727
};
2828
vec.push(action)
2929
}

benches/doubly_mutation_ends.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
1+
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
22
use orx_linked_list::*;
33
use orx_selfref_col::MemoryPolicy;
44
use rand::prelude::*;
@@ -15,15 +15,15 @@ enum Action {
1515
fn get_test_data(n: usize) -> Vec<Action> {
1616
let mut rng = ChaCha8Rng::seed_from_u64(56456);
1717
let mut vec: Vec<_> = (0..n)
18-
.map(|_| match rng.gen::<f32>() {
19-
x if x < 0.5 => Action::PushBack(rng.gen_range(0..n) as u32),
20-
_ => Action::PushFront(rng.gen_range(0..n) as u32),
18+
.map(|_| match rng.random::<f32>() {
19+
x if x < 0.5 => Action::PushBack(rng.random_range(0..n) as u32),
20+
_ => Action::PushFront(rng.random_range(0..n) as u32),
2121
})
2222
.collect();
2323
for _ in 0..2 * n {
24-
let action = match rng.gen::<f32>() {
25-
x if x < 0.25 => Action::PushBack(rng.gen_range(0..n) as u32),
26-
x if x < 0.50 => Action::PushFront(rng.gen_range(0..n) as u32),
24+
let action = match rng.random::<f32>() {
25+
x if x < 0.25 => Action::PushBack(rng.random_range(0..n) as u32),
26+
x if x < 0.50 => Action::PushFront(rng.random_range(0..n) as u32),
2727
x if x < 0.75 => Action::PopBack,
2828
_ => Action::PopFront,
2929
};

benches/doubly_shuffling_around.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
1+
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
22
use orx_linked_list::*;
33
use rand::prelude::*;
44
use rand_chacha::ChaCha8Rng;
@@ -16,8 +16,8 @@ fn get_moves(num_moves: usize, num_cities: usize) -> Vec<(usize, usize)> {
1616
let mut moves = vec![];
1717

1818
for _ in 0..num_moves {
19-
let a = rng.gen_range(0..num_cities);
20-
let b = rng.gen_range(0..num_cities);
19+
let a = rng.random_range(0..num_cities);
20+
let b = rng.random_range(0..num_cities);
2121
moves.push((a, b));
2222
}
2323

benches/singly_mutation_ends.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
1+
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
22
use orx_linked_list::*;
33
use orx_selfref_col::MemoryPolicy;
44
use rand::prelude::*;
@@ -13,11 +13,11 @@ enum Action {
1313
fn get_test_data(n: usize) -> Vec<Action> {
1414
let mut rng = ChaCha8Rng::seed_from_u64(56456);
1515
let mut vec: Vec<_> = (0..n)
16-
.map(|_| Action::PushFront(rng.gen_range(0..n) as u32))
16+
.map(|_| Action::PushFront(rng.random_range(0..n) as u32))
1717
.collect();
1818
for _ in 0..2 * n {
19-
let action = match rng.gen::<f32>() {
20-
x if x < 0.50 => Action::PushFront(rng.gen_range(0..n) as u32),
19+
let action = match rng.random::<f32>() {
20+
x if x < 0.50 => Action::PushFront(rng.random_range(0..n) as u32),
2121
_ => Action::PopFront,
2222
};
2323
vec.push(action)

examples/tour_mutations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ fn get_moves(num_moves: usize, num_cities: usize) -> Vec<(usize, usize)> {
1717
let mut moves = vec![];
1818

1919
for _ in 0..num_moves {
20-
let a = rng.gen_range(0..num_cities);
21-
let b = rng.gen_range(0..num_cities);
20+
let a = rng.random_range(0..num_cities);
21+
let b = rng.random_range(0..num_cities);
2222
moves.push((a, b));
2323
}
2424

src/pointers/doubly_ptr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub trait DoublyPointer<T> {
2929
/// Alternatively, you may use `NodeIdx` for safe access.
3030
#[inline(always)]
3131
unsafe fn node(&self) -> &Node<Doubly<T>> {
32-
&*self.raw_ptr()
32+
unsafe { &*self.raw_ptr() }
3333
}
3434

3535
/// Returns a mutable reference to the node.
@@ -45,7 +45,7 @@ pub trait DoublyPointer<T> {
4545
/// Alternatively, you may use `NodeIdx` for safe access.
4646
#[inline(always)]
4747
unsafe fn node_mut(&mut self) -> &mut Node<Doubly<T>> {
48-
&mut *self.raw_ptr()
48+
unsafe { &mut *self.raw_ptr() }
4949
}
5050

5151
/// Returns the pointer to the next node if exists; None otherwise.
@@ -61,7 +61,7 @@ pub trait DoublyPointer<T> {
6161
/// Alternatively, you may use `NodeIdx` for safe access.
6262
#[inline(always)]
6363
unsafe fn next(&self) -> Option<DoublyPtr<T>> {
64-
self.node().next().get().cloned()
64+
unsafe { self.node() }.next().get().cloned()
6565
}
6666

6767
/// Returns the pointer to the prev node if exists; None otherwise.
@@ -77,6 +77,6 @@ pub trait DoublyPointer<T> {
7777
/// Alternatively, you may use `NodeIdx` for safe access.
7878
#[inline(always)]
7979
unsafe fn prev(&self) -> Option<DoublyPtr<T>> {
80-
self.node().prev().get().cloned()
80+
unsafe { self.node() }.prev().get().cloned()
8181
}
8282
}

0 commit comments

Comments
 (0)