Skip to content

Commit 01a6636

Browse files
committed
Update for stabilized io::Error
As per rust-lang/rust#23919, the last argument was removed from Error::new, and the Clone, Eq, and PartialEq traits were removed from Error. Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 91975ca commit 01a6636

File tree

6 files changed

+7
-24
lines changed

6 files changed

+7
-24
lines changed

src/dynimage.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,7 @@ pub fn save_buffer<P>(path: P, buf: &[u8], width: u32, height: u32, color: color
562562
"ppm" => ppm::PPMEncoder::new(fout).encode(buf, width, height, color),
563563
format => Err(io::Error::new(
564564
io::ErrorKind::InvalidInput,
565-
"Unsupported image format.",
566-
Some(format!(
567-
"Image format image/{:?} is not supported.",
568-
format
569-
))
565+
&format!("Unsupported image format image/{:?}", format)[..],
570566
))
571567
}
572568
}

src/gif/encoder.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ where Container: Deref<Target=[u8]> + DerefMut {
6767
height > <u16 as Int>::max_value() as u32 {
6868
return Err(io::Error::new(
6969
io::ErrorKind::InvalidInput,
70-
"Image dimensions are to large for the gif format.",
71-
None
70+
"Image dimensions are too large for the gif format.",
7271
))
7372
}
7473
try!(w.write_u16::<LittleEndian>(width as u16));
@@ -331,8 +330,7 @@ where Container: Deref<Target=[u8]> + DerefMut {
331330
if n < 64 {
332331
return Err(io::Error::new(
333332
io::ErrorKind::InvalidInput,
334-
"Unsupported number of colors.",
335-
Some(format!("{} colors < 64 colors", n))
333+
&format!("Unsupported number of colors: {} < 64", n)[..],
336334
))
337335
}
338336
let nq = nq::NeuQuant::new(3, 256, &self.image);

src/image.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use animation::{Frame, Frames};
1414
use dynimage::decoder_to_image;
1515

1616
/// An enumeration of Image Errors
17-
#[derive(Clone, Debug, PartialEq, Eq)]
17+
#[derive(Debug)]
1818
pub enum ImageError {
1919
/// The Image is not formatted properly
2020
FormatError(String),

src/jpeg/encoder.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,7 @@ impl<'a, W: Write> JPEGEncoder<'a, W> {
243243
color::ColorType::GrayA(8) => try!(self.encode_gray(image, width as usize, height as usize, 2)),
244244
_ => return Err(io::Error::new(
245245
io::ErrorKind::InvalidInput,
246-
"Unsupported color type. Use 8 bit per channel RGB(A) or Gray(A) instead.",
247-
Some(format!(
248-
"Color type {:?} is not suppored by this JPEG encoder.",
249-
c
250-
))
246+
&format!("Unsupported color type {:?}. Use 8 bit per channel RGB(A) or Gray(A) instead.", c)[..],
251247
))
252248
};
253249

src/utils/bitstream.rs

-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ impl<R> BitReader for LsbReader<R> where R: Read {
8282
return Err(io::Error::new(
8383
io::ErrorKind::InvalidInput,
8484
"Cannot read more than 16 bits",
85-
None
8685
))
8786
}
8887
while self.bits < n {
@@ -104,7 +103,6 @@ impl<R> BitReader for MsbReader<R> where R: Read {
104103
return Err(io::Error::new(
105104
io::ErrorKind::InvalidInput,
106105
"Cannot read more than 16 bits",
107-
None
108106
))
109107
}
110108
while self.bits < n {

src/utils/lzw.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ impl DecodingDict {
6666
}
6767
None => return Err(io::Error::new(
6868
io::ErrorKind::InvalidInput,
69-
"invalid code occured",
70-
Some(format!("{} < {} expected", k, self.table.len()))
69+
&format!("invalid code occured: {} < {} expected", k, self.table.len())[..],
7170
))
7271
}
7372
self.buffer.push(cha);
@@ -138,11 +137,7 @@ where R: BitReader, W: Write {
138137
} else {
139138
return Err(io::Error::new(
140139
io::ErrorKind::InvalidInput,
141-
"Invalid code",
142-
Some(format!("expected {} <= {}",
143-
code,
144-
next_code)
145-
)
140+
&format!("Invalid code: expected {} <= {}", code, next_code)[..],
146141
))
147142
};
148143
try!(w.write(data));

0 commit comments

Comments
 (0)