Skip to content

Commit acc2d3e

Browse files
committed
only rand remains
1 parent 3d1a95d commit acc2d3e

File tree

4 files changed

+11
-27
lines changed

4 files changed

+11
-27
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ target/
44
book/
55
*.swp
66
lines.txt
7-
.idea/
7+
.idea/
8+
.skeptic-cache

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test-rand = []
1515
ansi_term = "0.11.0"
1616
approx = "0.3"
1717
base64 = "0.22.1"
18-
bitflags = "2.9.1"
18+
bitflags = "1.3.2"
1919
byteorder = "1.0"
2020
cc = "1.0"
2121
chrono = "0.4"
@@ -27,6 +27,7 @@ data-encoding = "2.1.0"
2727
env_logger = "0.11.3"
2828
flate2 = "1.0"
2929
glob = "0.3"
30+
image = "0.24"
3031

3132
lazy_static = "1.0"
3233
log = "0.4"

src/concurrency/parallel/rayon-thumbnails.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,22 @@ then saves them in a new folder called `thumbnails`.
99
images in parallel using [`par_iter`] calling [`DynamicImage::resize`].
1010

1111
```rust,edition2018,no_run
12-
# use error_chain::error_chain;
13-
12+
use anyhow::Result;
1413
use std::path::Path;
1514
use std::fs::create_dir_all;
1615
17-
# use error_chain::ChainedError;
1816
use glob::{glob_with, MatchOptions};
19-
use image::{FilterType, ImageError};
17+
use image::imageops::FilterType;
2018
use rayon::prelude::*;
2119
22-
# error_chain! {
23-
# foreign_links {
24-
# Image(ImageError);
25-
# Io(std::io::Error);
26-
# Glob(glob::PatternError);
27-
# }
28-
# }
29-
3020
fn main() -> Result<()> {
3121
let options: MatchOptions = Default::default();
3222
let files: Vec<_> = glob_with("*.jpg", options)?
3323
.filter_map(|x| x.ok())
3424
.collect();
3525
3626
if files.len() == 0 {
37-
error_chain::bail!("No .jpg files found in current directory");
27+
anyhow::bail!("No .jpg files found in current directory");
3828
}
3929
4030
let thumb_dir = "thumbnails";
@@ -46,12 +36,12 @@ fn main() -> Result<()> {
4636
.par_iter()
4737
.map(|path| {
4838
make_thumbnail(path, thumb_dir, 300)
49-
.map_err(|e| e.chain_err(|| path.display().to_string()))
39+
.map_err(|e| anyhow::anyhow!("Failed to process {}: {}", path.display(), e))
5040
})
5141
.filter_map(|x| x.err())
5242
.collect();
5343
54-
image_failures.iter().for_each(|x| println!("{}", x.display_chain()));
44+
image_failures.iter().for_each(|x| println!("{}", x));
5545
5646
println!("{} thumbnails saved successfully", files.len() - image_failures.len());
5747
Ok(())

src/concurrency/thread/threadpool-fractal.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,12 @@ Create [`ThreadPool`] with thread count equal to number of cores with [`num_cpus
1717
[`ImageBuffer::save`] writes the image to `output.png`.
1818

1919
```rust,edition2018,no_run
20-
# use error_chain::error_chain;
21-
use std::sync::mpsc::{channel, RecvError};
20+
use anyhow::Result;
21+
use std::sync::mpsc::channel;
2222
use threadpool::ThreadPool;
2323
use num::complex::Complex;
2424
use image::{ImageBuffer, Pixel, Rgb};
2525
#
26-
# error_chain! {
27-
# foreign_links {
28-
# MpscRecv(RecvError);
29-
# Io(std::io::Error);
30-
# Image(image::ImageError);
31-
# }
32-
# }
33-
#
3426
# // Function converting intensity values to RGB
3527
# // Based on http://www.efg2.com/Lab/ScienceAndEngineering/Spectra.htm
3628
# fn wavelength_to_rgb(wavelength: u32) -> Rgb<u8> {

0 commit comments

Comments
 (0)