Skip to content

Commit e27f688

Browse files
authored
Merge pull request #107 from kaksmet/deprecations
Fix some deprecation warnings
2 parents 2aa2df6 + 7feb6aa commit e27f688

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl<R: Read> Decoder<R> {
126126
// The metadata has already been read.
127127
return Ok(Vec::new());
128128
}
129-
else if self.frame.is_none() && (self.reader.read_u8()? != 0xFF || Marker::from_u8(try!(self.reader.read_u8())) != Some(Marker::SOI)) {
129+
else if self.frame.is_none() && (self.reader.read_u8()? != 0xFF || Marker::from_u8(self.reader.read_u8()?) != Some(Marker::SOI)) {
130130
return Err(Error::Format("first two bytes is not a SOI marker".to_owned()));
131131
}
132132

src/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub enum Error {
4141
/// An I/O error occurred while decoding the image.
4242
Io(IoError),
4343
/// An internal error occurred while decoding the image.
44-
Internal(Box<StdError>),
44+
Internal(Box<dyn StdError>),
4545
}
4646

4747
impl fmt::Display for Error {
@@ -65,7 +65,7 @@ impl StdError for Error {
6565
}
6666
}
6767

68-
fn cause(&self) -> Option<&StdError> {
68+
fn cause(&self) -> Option<&dyn StdError> {
6969
match *self {
7070
Error::Io(ref err) => Some(err),
7171
Error::Internal(ref err) => Some(&**err),

src/marker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Marker {
6767
match n {
6868
0x00 => None, // Byte stuffing
6969
0x01 => Some(TEM),
70-
0x02 ... 0xBF => Some(RES),
70+
0x02 ..= 0xBF => Some(RES),
7171
0xC0 => Some(SOF(0)),
7272
0xC1 => Some(SOF(1)),
7373
0xC2 => Some(SOF(2)),

src/parser.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ pub fn parse_sof<R: Read>(reader: &mut R, marker: Marker) -> Result<FrameInfo> {
113113

114114
let is_baseline = marker == SOF(0);
115115
let is_differential = match marker {
116-
SOF(0 ... 3) | SOF(9 ... 11) => false,
117-
SOF(5 ... 7) | SOF(13 ... 15) => true,
116+
SOF(0 ..= 3) | SOF(9 ..= 11) => false,
117+
SOF(5 ..= 7) | SOF(13 ..= 15) => true,
118118
_ => panic!(),
119119
};
120120
let coding_process = match marker {
@@ -124,8 +124,8 @@ pub fn parse_sof<R: Read>(reader: &mut R, marker: Marker) -> Result<FrameInfo> {
124124
_ => panic!(),
125125
};
126126
let entropy_coding = match marker {
127-
SOF(0 ... 3) | SOF(5 ... 7) => EntropyCoding::Huffman,
128-
SOF(9 ... 11) | SOF(13 ... 15) => EntropyCoding::Arithmetic,
127+
SOF(0 ..= 3) | SOF(5 ..= 7) => EntropyCoding::Huffman,
128+
SOF(9 ..= 11) | SOF(13 ..= 15) => EntropyCoding::Arithmetic,
129129
_ => panic!(),
130130
};
131131

@@ -296,8 +296,8 @@ pub fn parse_sos<R: Read>(reader: &mut R, frame: &FrameInfo) -> Result<ScanInfo>
296296
return Err(Error::Format("scan with more than one component and more than 10 blocks per MCU".to_owned()));
297297
}
298298

299-
let spectral_selection_start = try!(reader.read_u8());
300-
let spectral_selection_end = try!(reader.read_u8());
299+
let spectral_selection_start = reader.read_u8()?;
300+
let spectral_selection_end = reader.read_u8()?;
301301

302302
let byte = reader.read_u8()?;
303303
let successive_approximation_high = byte >> 4;

src/upsampler.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub struct Upsampler {
77
}
88

99
struct UpsamplerComponent {
10-
upsampler: Box<Upsample + Sync>,
10+
upsampler: Box<dyn Upsample + Sync>,
1111
width: usize,
1212
height: usize,
1313
row_stride: usize,
@@ -75,7 +75,7 @@ struct UpsamplerGeneric {
7575
fn choose_upsampler(sampling_factors: (u8, u8),
7676
max_sampling_factors: (u8, u8),
7777
output_width: u16,
78-
output_height: u16) -> Result<Box<Upsample + Sync>> {
78+
output_height: u16) -> Result<Box<dyn Upsample + Sync>> {
7979
let h1 = sampling_factors.0 == max_sampling_factors.0 || output_width == 1;
8080
let v1 = sampling_factors.1 == max_sampling_factors.1 || output_height == 1;
8181
let h2 = sampling_factors.0 * 2 == max_sampling_factors.0;

0 commit comments

Comments
 (0)