Prefer explicit conversion over as

The discriminant of some enum types can be retrieved with the `as`
operator and in C style enums it is also possible to set a specific
discriminant. However, that may silently change—breaking the value
written to the file. It is better to use that technique mostly for ffi
purposes.
This commit is contained in:
Andreas Molzer committed 2019-11-10 23:20:19 +01:00
1 parent a6696ab02f
commit 517638a38f
1 file changed
+2 -2
+2 -2
View File
@@ -438,7 +438,7 @@ impl<'a, W: 'a + Write + Seek> DirectoryEncoder<'a, W> {
}
self.ifd
.insert(tag.to_u16(), (<T>::FIELD_TYPE as u16, value.count(), bytes));
.insert(tag.to_u16(), (<T>::FIELD_TYPE.to_u16(), value.count(), bytes));
}
fn write_directory(&mut self) -> TiffResult<u64> {
@@ -565,7 +565,7 @@ impl<'a, W: 'a + Write + Seek, T: ColorType> ImageEncoder<'a, W, T> {
encoder.write_tag(Tag::Compression, 1u16);
encoder.write_tag(Tag::BitsPerSample, <T>::BITS_PER_SAMPLE);
encoder.write_tag(Tag::PhotometricInterpretation, <T>::TIFF_VALUE as u16);
encoder.write_tag(Tag::PhotometricInterpretation, <T>::TIFF_VALUE.to_u16());
encoder.write_tag(Tag::RowsPerStrip, rows_per_strip as u32);