Skip to content

Commit 4d7e36d

Browse files
author
HeroicKatora
authored
Merge pull request #136 from linkmauve/fix-warning
Fix deprecated Error::description() warning
2 parents 83368db + 9a46fe4 commit 4d7e36d

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ byteorder = "1.0"
1515
rayon = { version = "1.0", optional = true }
1616

1717
[dev-dependencies]
18-
png = "0.14"
18+
png = "0.15"
1919
walkdir = "2.0"
2020
criterion = "0.3"
2121

examples/decode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ fn main() {
2424

2525
let output_file = File::create(output_path).unwrap();
2626
let mut encoder = png::Encoder::new(output_file, info.width as u32, info.height as u32);
27-
encoder.set(png::BitDepth::Eight);
27+
encoder.set_depth(png::BitDepth::Eight);
2828

2929
match info.pixel_format {
30-
jpeg::PixelFormat::L8 => encoder.set(png::ColorType::Grayscale),
31-
jpeg::PixelFormat::RGB24 => encoder.set(png::ColorType::RGB),
30+
jpeg::PixelFormat::L8 => encoder.set_color(png::ColorType::Grayscale),
31+
jpeg::PixelFormat::RGB24 => encoder.set_color(png::ColorType::RGB),
3232
jpeg::PixelFormat::CMYK32 => {
3333
data = cmyk_to_rgb(&mut data);
34-
encoder.set(png::ColorType::RGB)
34+
encoder.set_color(png::ColorType::RGB)
3535
},
3636
};
3737

src/error.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,7 @@ impl fmt::Display for Error {
5454
}
5555

5656
impl StdError for Error {
57-
fn description(&self) -> &str {
58-
match *self {
59-
Error::Format(_) => "invalid JPEG format",
60-
Error::Unsupported(_) => "unsupported JPEG feature",
61-
Error::Io(ref err) => err.description(),
62-
Error::Internal(ref err) => err.description(),
63-
}
64-
}
65-
66-
fn cause(&self) -> Option<&dyn StdError> {
57+
fn source(&self) -> Option<&(dyn StdError + 'static)> {
6758
match *self {
6859
Error::Io(ref err) => Some(err),
6960
Error::Internal(ref err) => Some(&**err),

tests/reftest/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use jpeg;
2-
use png::{self, HasParameters};
2+
use png;
33
use std::cmp;
44
use std::fs::File;
55
use std::path::Path;
@@ -94,8 +94,8 @@ fn reftest_decoder<T: std::io::Read>(mut decoder: jpeg::Decoder<T>, path: &Path,
9494
let output_path = path.with_file_name(format!("{}-diff.png", path.file_stem().unwrap().to_str().unwrap()));
9595
let output = File::create(&output_path).unwrap();
9696
let mut encoder = png::Encoder::new(output, info.width as u32, info.height as u32);
97-
encoder.set(png::BitDepth::Eight);
98-
encoder.set(ref_pixel_format);
97+
encoder.set_depth(png::BitDepth::Eight);
98+
encoder.set_color(ref_pixel_format);
9999
encoder.write_header().expect("png failed to write header").write_image_data(&pixels).expect("png failed to write data");
100100

101101
panic!("decoding difference: {:?}, maximum difference was {}", output_path, max_diff);

0 commit comments

Comments
 (0)