diff --git a/src/de/decoder.rs b/src/de/decoder.rs index c1d89a7a..b538b07b 100644 --- a/src/de/decoder.rs +++ b/src/de/decoder.rs @@ -28,7 +28,7 @@ pub struct DecoderImpl { impl DecoderImpl { /// Construct a new Decoder - pub fn new(reader: R, config: C) -> DecoderImpl { + pub const fn new(reader: R, config: C) -> DecoderImpl { DecoderImpl { reader, config, diff --git a/src/de/read.rs b/src/de/read.rs index b2ba5ccf..21c35db7 100644 --- a/src/de/read.rs +++ b/src/de/read.rs @@ -66,7 +66,7 @@ pub struct SliceReader<'storage> { impl<'storage> SliceReader<'storage> { /// Constructs a slice reader - pub fn new(bytes: &'storage [u8]) -> SliceReader<'storage> { + pub const fn new(bytes: &'storage [u8]) -> SliceReader<'storage> { SliceReader { slice: bytes } } } diff --git a/src/enc/encoder.rs b/src/enc/encoder.rs index 564da0bb..7f0bf222 100644 --- a/src/enc/encoder.rs +++ b/src/enc/encoder.rs @@ -27,7 +27,7 @@ pub struct EncoderImpl { impl EncoderImpl { /// Create a new Encoder - pub fn new(writer: W, config: C) -> EncoderImpl { + pub const fn new(writer: W, config: C) -> EncoderImpl { EncoderImpl { writer, config } } diff --git a/src/error.rs b/src/error.rs index 8c6ece4e..7fb9c5c0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -250,7 +250,7 @@ pub enum IntegerType { impl IntegerType { /// Change the `Ux` value to the associated `Ix` value. /// Returns the old value if `self` is already `Ix`. - pub(crate) fn into_signed(self) -> Self { + pub(crate) const fn into_signed(self) -> Self { match self { Self::U8 => Self::I8, Self::U16 => Self::I16, diff --git a/src/features/impl_std.rs b/src/features/impl_std.rs index 96721053..04fae2f1 100644 --- a/src/features/impl_std.rs +++ b/src/features/impl_std.rs @@ -37,7 +37,7 @@ pub(crate) struct IoReader { } impl IoReader { - pub fn new(reader: R) -> Self { + pub const fn new(reader: R) -> Self { Self { reader } } } @@ -109,7 +109,7 @@ impl<'a, W: std::io::Write> IoWriter<'a, W> { } } - pub fn bytes_written(&self) -> usize { + pub const fn bytes_written(&self) -> usize { self.bytes_written } } diff --git a/src/varint/decode_unsigned.rs b/src/varint/decode_unsigned.rs index d6b17a64..de0f0b95 100644 --- a/src/varint/decode_unsigned.rs +++ b/src/varint/decode_unsigned.rs @@ -190,7 +190,7 @@ where #[inline(never)] #[cold] -fn invalid_varint_discriminant( +const fn invalid_varint_discriminant( expected: IntegerType, found: IntegerType, ) -> Result {