diff --git a/Changelog.md b/Changelog.md index 7264f05d..ba9e255c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -16,6 +16,11 @@ ### Misc Changes +- [#481]: Removed the uses of `const fn` added in version 0.24 in favor of a lower minimum + supported Rust version. Minimum supported Rust version is now tested in the CI. + +[#481]: https://github.com/tafia/quick-xml/pull/481 + ## 0.25.0 -- 2022-09-10 ### Bug Fixes diff --git a/src/de/escape.rs b/src/de/escape.rs index 2a05a250..446b1d2f 100644 --- a/src/de/escape.rs +++ b/src/de/escape.rs @@ -25,7 +25,7 @@ pub struct EscapedDeserializer<'a> { } impl<'a> EscapedDeserializer<'a> { - pub const fn new(escaped_value: Cow<'a, [u8]>, decoder: Decoder, escaped: bool) -> Self { + pub fn new(escaped_value: Cow<'a, [u8]>, decoder: Decoder, escaped: bool) -> Self { EscapedDeserializer { decoder, escaped_value, diff --git a/src/de/simple_type.rs b/src/de/simple_type.rs index 19211099..09f0249f 100644 --- a/src/de/simple_type.rs +++ b/src/de/simple_type.rs @@ -546,7 +546,7 @@ impl<'de, 'a> SimpleTypeDeserializer<'de, 'a> { /// Constructor for tests #[inline] - const fn new(content: CowRef<'de, 'a>, escaped: bool, decoder: Decoder) -> Self { + fn new(content: CowRef<'de, 'a>, escaped: bool, decoder: Decoder) -> Self { Self { content, escaped, diff --git a/src/encoding.rs b/src/encoding.rs index 2f549d88..50bfe2ea 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -61,7 +61,7 @@ impl Decoder { /// /// [`decode`]: Self::decode #[cfg(feature = "encoding")] - pub const fn encoding(&self) -> &'static Encoding { + pub fn encoding(&self) -> &'static Encoding { self.encoding } diff --git a/src/events/attributes.rs b/src/events/attributes.rs index 3895d71e..7eb2b27b 100644 --- a/src/events/attributes.rs +++ b/src/events/attributes.rs @@ -191,7 +191,7 @@ pub struct Attributes<'a> { impl<'a> Attributes<'a> { /// Internal constructor, used by `BytesStart`. Supplies data in reader's encoding #[inline] - pub(crate) const fn wrap(buf: &'a [u8], pos: usize, html: bool) -> Self { + pub(crate) fn wrap(buf: &'a [u8], pos: usize, html: bool) -> Self { Self { bytes: buf, state: IterState::new(pos, html), @@ -199,12 +199,12 @@ impl<'a> Attributes<'a> { } /// Creates a new attribute iterator from a buffer. - pub const fn new(buf: &'a str, pos: usize) -> Self { + pub fn new(buf: &'a str, pos: usize) -> Self { Self::wrap(buf.as_bytes(), pos, false) } /// Creates a new attribute iterator from a buffer, allowing HTML attribute syntax. - pub const fn html(buf: &'a str, pos: usize) -> Self { + pub fn html(buf: &'a str, pos: usize) -> Self { Self::wrap(buf.as_bytes(), pos, true) } @@ -412,7 +412,7 @@ impl Attr { impl<'a> Attr<&'a [u8]> { /// Returns the key value #[inline] - pub const fn key(&self) -> QName<'a> { + pub fn key(&self) -> QName<'a> { QName(match self { Attr::DoubleQ(key, _) => key, Attr::SingleQ(key, _) => key, @@ -425,7 +425,7 @@ impl<'a> Attr<&'a [u8]> { /// /// [HTML specification]: https://www.w3.org/TR/2012/WD-html-markup-20120329/syntax.html#syntax-attr-empty #[inline] - pub const fn value(&self) -> &'a [u8] { + pub fn value(&self) -> &'a [u8] { match self { Attr::DoubleQ(_, value) => value, Attr::SingleQ(_, value) => value, @@ -514,7 +514,7 @@ pub(crate) struct IterState { } impl IterState { - pub const fn new(offset: usize, html: bool) -> Self { + pub fn new(offset: usize, html: bool) -> Self { Self { state: State::Next(offset), html, diff --git a/src/events/mod.rs b/src/events/mod.rs index 9bf37729..7ebed260 100644 --- a/src/events/mod.rs +++ b/src/events/mod.rs @@ -72,7 +72,7 @@ pub struct BytesStart<'a> { impl<'a> BytesStart<'a> { /// Internal constructor, used by `Reader`. Supplies data in reader's encoding #[inline] - pub(crate) const fn wrap(content: &'a [u8], name_len: usize) -> Self { + pub(crate) fn wrap(content: &'a [u8], name_len: usize) -> Self { BytesStart { buf: Cow::Borrowed(content), name_len, @@ -344,7 +344,7 @@ impl<'a> BytesDecl<'a> { } /// Creates a `BytesDecl` from a `BytesStart` - pub const fn from_start(start: BytesStart<'a>) -> Self { + pub fn from_start(start: BytesStart<'a>) -> Self { Self { content: start } } @@ -549,7 +549,7 @@ pub struct BytesEnd<'a> { impl<'a> BytesEnd<'a> { /// Internal constructor, used by `Reader`. Supplies data in reader's encoding #[inline] - pub(crate) const fn wrap(name: Cow<'a, [u8]>) -> Self { + pub(crate) fn wrap(name: Cow<'a, [u8]>) -> Self { BytesEnd { name } } diff --git a/src/name.rs b/src/name.rs index 3bdc7220..ac1c714c 100644 --- a/src/name.rs +++ b/src/name.rs @@ -21,7 +21,7 @@ pub struct QName<'a>(pub &'a [u8]); impl<'a> QName<'a> { /// Converts this name to an internal slice representation. #[inline(always)] - pub const fn into_inner(self) -> &'a [u8] { + pub fn into_inner(self) -> &'a [u8] { self.0 } @@ -138,7 +138,7 @@ pub struct LocalName<'a>(&'a [u8]); impl<'a> LocalName<'a> { /// Converts this name to an internal slice representation. #[inline(always)] - pub const fn into_inner(self) -> &'a [u8] { + pub fn into_inner(self) -> &'a [u8] { self.0 } } @@ -188,7 +188,7 @@ pub struct Prefix<'a>(&'a [u8]); impl<'a> Prefix<'a> { /// Extracts internal slice #[inline(always)] - pub const fn into_inner(self) -> &'a [u8] { + pub fn into_inner(self) -> &'a [u8] { self.0 } } @@ -253,7 +253,7 @@ impl<'a> Namespace<'a> { /// [non-normalized]: https://www.w3.org/TR/REC-xml/#AVNormalize /// [IRI reference]: https://datatracker.ietf.org/doc/html/rfc3987 #[inline(always)] - pub const fn into_inner(self) -> &'a [u8] { + pub fn into_inner(self) -> &'a [u8] { self.0 } //TODO: implement value normalization and use it when comparing namespaces diff --git a/src/reader/mod.rs b/src/reader/mod.rs index 0d94b2a4..77ed187c 100644 --- a/src/reader/mod.rs +++ b/src/reader/mod.rs @@ -377,7 +377,7 @@ enum EncodingRef { #[cfg(feature = "encoding")] impl EncodingRef { #[inline] - const fn encoding(&self) -> &'static Encoding { + fn encoding(&self) -> &'static Encoding { match self { Self::Implicit(e) => e, Self::Explicit(e) => e, @@ -386,7 +386,7 @@ impl EncodingRef { } } #[inline] - const fn can_be_refined(&self) -> bool { + fn can_be_refined(&self) -> bool { match self { Self::Implicit(_) | Self::BomDetected(_) => true, Self::Explicit(_) | Self::XmlDetected(_) => false, @@ -531,7 +531,7 @@ impl Reader { } /// Gets a reference to the underlying reader. - pub const fn get_ref(&self) -> &R { + pub fn get_ref(&self) -> &R { &self.reader } @@ -543,7 +543,7 @@ impl Reader { /// Gets the current byte position in the input data. /// /// Useful when debugging errors. - pub const fn buffer_position(&self) -> usize { + pub fn buffer_position(&self) -> usize { // when internal state is OpenedTag, we have actually read until '<', // which we don't want to show if let ParseState::OpenedTag = self.parser.state { @@ -561,7 +561,7 @@ impl Reader { /// If `encoding` feature is enabled and no encoding is specified in declaration, /// defaults to UTF-8. #[inline] - pub const fn decoder(&self) -> Decoder { + pub fn decoder(&self) -> Decoder { self.parser.decoder() } } @@ -848,7 +848,7 @@ impl ReadElementState { /// A function to check whether the byte is a whitespace (blank, new line, carriage return or tab) #[inline] -pub(crate) const fn is_whitespace(b: u8) -> bool { +pub(crate) fn is_whitespace(b: u8) -> bool { match b { b' ' | b'\r' | b'\n' | b'\t' => true, _ => false, diff --git a/src/reader/parser.rs b/src/reader/parser.rs index a8f70add..dc5e37a2 100644 --- a/src/reader/parser.rs +++ b/src/reader/parser.rs @@ -236,7 +236,7 @@ impl Parser { /// /// If `encoding` feature is enabled and no encoding is specified in declaration, /// defaults to UTF-8. - pub const fn decoder(&self) -> Decoder { + pub fn decoder(&self) -> Decoder { Decoder { #[cfg(feature = "encoding")] encoding: self.encoding.encoding(), diff --git a/src/reader/slice_reader.rs b/src/reader/slice_reader.rs index 906437a8..fd4dbaaa 100644 --- a/src/reader/slice_reader.rs +++ b/src/reader/slice_reader.rs @@ -353,7 +353,7 @@ mod test { use crate::reader::XmlSource; /// Default buffer constructor just pass the byte array from the test - const fn identity(input: T) -> T { + fn identity(input: T) -> T { input } diff --git a/src/se/mod.rs b/src/se/mod.rs index 42fed721..9f734690 100644 --- a/src/se/mod.rs +++ b/src/se/mod.rs @@ -117,7 +117,7 @@ impl<'r, W: Write> Serializer<'r, W> { /// Note, that attempt to serialize a non-struct (including unit structs /// and newtype structs) will end up to an error. Use `with_root` to create /// serializer with explicitly defined root element name - pub const fn new(writer: W) -> Self { + pub fn new(writer: W) -> Self { Self::with_root(Writer::new(writer), None) } @@ -169,7 +169,7 @@ impl<'r, W: Write> Serializer<'r, W> { /// r#""# /// ); /// ``` - pub const fn with_root(writer: Writer, root_tag: Option<&'r str>) -> Self { + pub fn with_root(writer: Writer, root_tag: Option<&'r str>) -> Self { Self { writer, root_tag } } diff --git a/src/writer.rs b/src/writer.rs index 26095eed..bf12d83c 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -61,7 +61,7 @@ pub struct Writer { impl Writer { /// Creates a `Writer` from a generic writer. - pub const fn new(inner: W) -> Writer { + pub fn new(inner: W) -> Writer { Writer { writer: inner, indent: None,