Skip to content

Commit 63827d6

Browse files
committed
one fifty five
1 parent eedb8ce commit 63827d6

File tree

26 files changed

+116
-84
lines changed

26 files changed

+116
-84
lines changed

.github/workflows/mdbook-test.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,19 @@ jobs:
1717
uses: actions-rust-lang/setup-rust-toolchain@v1
1818
with:
1919
cache: 'true'
20-
toolchain: nightly
20+
toolchain: stable
2121

2222
- name: Run tests
2323
id: cargo_test
2424
run: |
25-
cargo +nightly test --test skeptic -- -Z unstable-options --format junit --report-time --test-threads=1 | tee ./TEST-cookbook.xml
25+
cargo test --test skeptic -- --test-threads=1
2626
27-
- name: List files for debugging
27+
- name: Test Results
2828
if: always()
29-
run: ls -R
30-
31-
- name: Publish Test Report
32-
uses: mikepenz/action-junit-report@v5.2.0
33-
if: always()
34-
with:
35-
fail_on_failure: true
36-
require_tests: true
37-
summary: ${{ steps.cargo_test.outputs.summary }}
38-
report_paths: '**/TEST-*.xml'
29+
run: |
30+
if [ ${{ steps.cargo_test.outcome }} == 'success' ]; then
31+
echo "✅ All tests passed!"
32+
else
33+
echo "❌ Some tests failed. Check the logs above for details."
34+
exit 1
35+
fi

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ reqwest = { version = "0.12", features = ["blocking", "json", "stream"] }
4949
ring = "0.17"
5050
rusqlite = { version = "0.32", features = ["chrono"] }
5151
same-file = "1.0"
52+
select = "0.6.0"
5253

5354
semver = "1.0"
5455
serde = { version = "1.0", features = ["derive"] }
@@ -70,9 +71,9 @@ walkdir = "2.5"
7071
syslog = "5.0"
7172

7273
[build-dependencies]
73-
skeptic = { git = "https://github.com/andygauge/rust-skeptic", branch = "rlib-patch" }
74+
skeptic = { git = "https://github.com/AndyGauge/rust-skeptic", branch = "rlib-patch" }
7475
walkdir = "2.5"
7576

7677
[dev-dependencies]
77-
skeptic = { git = "https://github.com/andygauge/rust-skeptic", branch = "rlib-patch" }
78+
skeptic = { git = "https://github.com/AndyGauge/rust-skeptic", branch = "rlib-patch" }
7879
walkdir = "2.5"

src/about.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ Consider this example for "generate random numbers within a range":
5656

5757
[![rand-badge]][rand] [![cat-science-badge]][cat-science]
5858

59-
```rust,edition2018,ignore
59+
```rust,edition2018
6060
use rand::Rng;
6161
6262
fn main() {
63-
let mut rng = rand::thread_rng();
64-
let random_number: u32 = rng.gen();
63+
let mut rng = rand::rng();
64+
let random_number: u32 = rng.random();
6565
println!("Random number: {}", random_number);
6666
}
6767
```

src/algorithms/randomness/rand-choose.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Randomly generates a string of given length ASCII characters with custom
66
user-defined bytestring, with [`gen_range`].
77

8-
```rust,edition2018,ignore
8+
```rust,edition2018
99
use rand::Rng;
1010
1111
const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
@@ -14,7 +14,7 @@ const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
1414
const PASSWORD_LEN: usize = 30;
1515
1616
fn main() {
17-
let mut rng = rand::thread_rng();
17+
let mut rng = rand::rng();
1818
1919
let password: String = (0..PASSWORD_LEN)
2020
.map(|_| {

src/algorithms/randomness/rand-custom.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,28 @@
55
Randomly generates a tuple `(i32, bool, f64)` and variable of user defined type `Point`.
66
Implements the [`Distribution`] trait on type Point for [`Standard`] in order to allow random generation.
77

8-
```rust,edition2018,no_run
8+
```rust,edition2018
99
use rand::Rng;
10-
use rand::distributions::{Distribution, Standard};
1110
1211
#[derive(Debug)]
1312
struct Point {
1413
x: i32,
1514
y: i32,
1615
}
1716
18-
impl Distribution<Point> for Standard {
19-
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Point {
20-
let rand_x: i32 = rng.gen();
21-
let rand_y: i32 = rng.gen();
17+
impl Point {
18+
fn random<R: Rng>(rng: &mut R) -> Self {
2219
Point {
23-
x: rand_x,
24-
y: rand_y,
20+
x: rng.random(),
21+
y: rng.random(),
2522
}
2623
}
2724
}
2825
2926
fn main() {
30-
let mut rng = rand::thread_rng();
31-
let rand_tuple = rng.gen::<(i32, bool, f64)>();
32-
let rand_point: Point = rng.gen();
27+
let mut rng = rand::rng();
28+
let rand_tuple = rng.random::<(i32, bool, f64)>();
29+
let rand_point = Point::random(&mut rng);
3330
println!("Random tuple: {:?}", rand_tuple);
3431
println!("Random Point: {:?}", rand_point);
3532
}

src/algorithms/randomness/rand-dist.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ generator [`rand::Rng`].
1212
The [distributions available are documented here][rand-distributions].
1313
An example using the [`Normal`] distribution is shown below.
1414

15-
```rust,edition2018,ignore
15+
```rust,edition2018
1616
use rand::Rng;
1717
use rand_distr::{Distribution, LogNormal, Normal};
1818
1919
fn main() {
20-
let mut rng = rand::thread_rng();
21-
let normal = Normal::new(2.0, 3.0).unwrap();
22-
let log_normal = LogNormal::new(1.0, 0.5).unwrap();
20+
let mut rng = rand::rng();
21+
let normal = Normal::new(2.0, 3.0)
22+
.expect("Failed to create normal distribution");
23+
let log_normal = LogNormal::new(1.0, 0.5)
24+
.expect("Failed to create log-normal distribution");
2325
2426
let v = normal.sample(&mut rng);
2527
println!("{} is from a N(2, 9) distribution", v);

src/algorithms/randomness/rand-passwd.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@
55
Randomly generates a string of given length ASCII characters in the range `A-Z,
66
a-z, 0-9`, with [`Alphanumeric`] sample.
77

8-
```rust,edition2018,no_run
9-
use rand::{thread_rng, Rng};
10-
use rand::distributions::Alphanumeric;
8+
```rust,edition2018
9+
use rand::Rng;
1110
1211
fn main() {
13-
let rand_string: String = thread_rng()
14-
.sample_iter(&Alphanumeric)
15-
.take(30)
16-
.map(char::from)
12+
const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
13+
abcdefghijklmnopqrstuvwxyz\
14+
0123456789";
15+
const PASSWORD_LEN: usize = 30;
16+
let mut rng = rand::rng();
17+
18+
let password: String = (0..PASSWORD_LEN)
19+
.map(|_| {
20+
let idx = rng.random_range(0..CHARSET.len());
21+
CHARSET[idx] as char
22+
})
1723
.collect();
1824
19-
println!("{}", rand_string);
25+
println!("{}", password);
2026
}
2127
```
2228

src/algorithms/randomness/rand-range.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
Generates a random value within half-open `[0, 10)` range (not including `10`) with [`Rng::gen_range`].
66

7-
```rust,edition2018,ignore
7+
```rust,edition2018
88
use rand::Rng;
99
1010
fn main() {
11-
let mut rng = rand::thread_rng();
11+
let mut rng = rand::rng();
1212
println!("Integer: {}", rng.gen_range(0..10));
1313
println!("Float: {}", rng.gen_range(0.0..10.0));
1414
}
@@ -18,13 +18,14 @@ fn main() {
1818
This has the same effect, but may be faster when repeatedly generating numbers
1919
in the same range.
2020

21-
```rust,edition2018,ignore
21+
```rust,edition2018
2222
use rand::Rng;
2323
use rand_distr::{Distribution, Uniform};
2424
2525
fn main() {
26-
let mut rng = rand::thread_rng();
27-
let die = Uniform::from(1..7);
26+
let mut rng = rand::rng();
27+
let die = Uniform::new_inclusive(1, 6)
28+
.expect("Failed to create uniform distribution: invalid range");
2829
2930
loop {
3031
let throw = die.sample(&mut rng);

src/algorithms/randomness/rand.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ initialized generator. Integers are uniformly distributed over the range of the
88
type, and floating point numbers are uniformly distributed from 0 up to but not
99
including 1.
1010

11-
```rust,edition2018,ignore
11+
```rust,edition2018
1212
use rand::Rng;
1313
1414
fn main() {

src/concurrency/parallel/rayon-thumbnails.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ then saves them in a new folder called `thumbnails`.
88
[`glob::glob_with`] finds jpeg files in current directory. `rayon` resizes
99
images in parallel using [`par_iter`] calling [`DynamicImage::resize`].
1010

11-
```rust,edition2018,ignore,no_run
11+
```rust,edition2018,no_run
1212
use anyhow::Result;
1313
use std::path::Path;
1414
use std::fs::create_dir_all;

0 commit comments

Comments
 (0)