Skip to content

Commit 234b2ba

Browse files
authored
Merge pull request #318 from image-rs/release-0.11
Fix a couple of nits
2 parents d38fba4 + a63a013 commit 234b2ba

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/decoder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ impl<R: Read + Seek> Decoder<R> {
12771277
///
12781278
/// It will re-allocate the buffer into the correct type and size, within the decoder's
12791279
/// configured limits, and then pass it to the underlying method. This is essentially a
1280-
/// type-safe wrapper around the raw [`Self::read_chunk_to_bytes`] method.
1280+
/// type-safe wrapper around the raw [`Self::read_chunk_bytes`] method.
12811281
///
12821282
/// Note that for planar images each chunk contains only one sample of the underlying data.
12831283
pub fn read_chunk_to_buffer(

src/tags.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ macro_rules! tags {
2020

2121
impl $name {
2222
#[inline(always)]
23-
fn __from_inner_type(n: $ty) -> Result<Self, $ty> {
23+
const fn __from_inner_type(n: $ty) -> Result<Self, $ty> {
2424
match n {
2525
$( $val => Ok($name::$tag), )*
2626
n => Err(n),
2727
}
2828
}
2929

3030
#[inline(always)]
31-
fn __to_inner_type(&self) -> $ty {
31+
const fn __to_inner_type(&self) -> $ty {
3232
match *self {
3333
$( $name::$tag => $val, )*
3434
$( $name::Unknown($unknown_doc) => { $unknown_doc }, )*
@@ -42,19 +42,25 @@ macro_rules! tags {
4242
($name:tt, u16, $($unknown_doc:ident)*) => {
4343
impl $name {
4444
#[inline(always)]
45-
pub fn from_u16(val: u16) -> Option<Self> {
46-
Self::__from_inner_type(val).ok()
45+
pub const fn from_u16(val: u16) -> Option<Self> {
46+
match Self::__from_inner_type(val) {
47+
Ok(v) => Some(v),
48+
Err(_) => None,
49+
}
4750
}
4851

4952
$(
5053
#[inline(always)]
51-
pub fn from_u16_exhaustive($unknown_doc: u16) -> Self {
52-
Self::__from_inner_type($unknown_doc).unwrap_or_else(|_| $name::Unknown($unknown_doc))
54+
pub const fn from_u16_exhaustive($unknown_doc: u16) -> Self {
55+
match Self::__from_inner_type($unknown_doc) {
56+
Ok(v) => v,
57+
Err(_) => $name::Unknown($unknown_doc),
58+
}
5359
}
5460
)*
5561

5662
#[inline(always)]
57-
pub fn to_u16(&self) -> u16 {
63+
pub const fn to_u16(&self) -> u16 {
5864
Self::__to_inner_type(self)
5965
}
6066
}

0 commit comments

Comments
 (0)